postgres/gcppostgres: redact password from connection errors - #3752
Merged
vangent merged 1 commit intoJul 23, 2026
Conversation
Both lazyCredsOpener.OpenPostgresURL (on ADC load failure) and URLOpener.OpenPostgresURL (on malformed instance path) format the raw *url.URL into the returned error with %v, which includes any userinfo password verbatim. Use url.URL.Redacted() instead, matching the fix already applied in secrets/localsecrets and the docstore/pubsub default dialers.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3752 +/- ##
=========================================
Coverage ? 75.29%
=========================================
Files ? 104
Lines ? 14202
Branches ? 0
=========================================
Hits ? 10694
Misses ? 2770
Partials ? 738 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
Thanks for fixing these issues! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OSS VRP Issue 541240334
Both error paths in gcppostgres.go format the raw *url.URL with %v:
Since url.URL's default String() method includes the userinfo password in plain text, any password supplied in the gcppostgres:// URL ends up in the returned error in both cases.
This switches both call sites to url.URL.Redacted(), which masks the password with "xxxxx" while keeping the rest of the URL for debugging. Added a test covering the malformed-path case.
go test ./postgres/... passes.