fix: redact DSN passwords from connection error messages and label the failing side - #78
Open
Apakottur wants to merge 1 commit into
Open
fix: redact DSN passwords from connection error messages and label the failing side#78Apakottur wants to merge 1 commit into
Apakottur wants to merge 1 commit into
Conversation
libpq echoes the raw connection string (password included) when a DSN fails URI parsing and falls back to keyword/value parsing. Scrub any password found in the DSN from the wrapped error text, and label which side (source/target) failed so the redacted message stays actionable. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PVv1LWaK7pBKshBE18DJzv
Apakottur
force-pushed
the
feat/redact-dsn-password
branch
from
July 29, 2026 11:32
343b464 to
85e243d
Compare
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.
What
Scrub passwords from connection error messages. libpq echoes the raw connection string — password included — when a DSN fails URI parsing and falls back to
keyword=valueparsing; pgmig wrapped that text verbatim into the user-facing error, leaking the password to stderr and to library users' logs. Errors now also say which side (source/target) failed, so the redacted message stays actionable.Behavior
Before:
After:
Notes
postgresql://scheme, andpassword=...keyword form incl. quoted values) and replaced with***wherever they appear in the wrapped error text. This covers any fragment libpq chooses to echo, and applies to all wrapped connect errors (auth/network too) as defense in depth, even though today only parse errors echo the DSN.DbConnection.connect, the single place a DSN is handed to the driver, so every connection path is covered.labelis threadedagenerate->introspect_db->DbReadOnlyConnection.connect->DbConnection.connect.labelis a required parameter rather than an optional one: an optional label needs anif labelbranch whose unlabeled-failure arm nothing exercises, which would fail the 100% coverage gate. The cost is mechanicallabel=additions at the test call sites._db,_introspect._engine,_redact), so this is not a public-facing signature change.main— the original branch predated the async introspection refactor, so the change is reapplied againstDbConnectionrather than the since-removedbuild_db_info.