Refuse a malformed DATABASE_URL without printing the password - #405
Merged
Conversation
davidmckayv
requested review from
MikeRyanDev,
guidovizoso and
tylerslaton
as code owners
September 6, 2026 17:49
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 this changes
addressOfinserver/src/db/client.tstakesDATABASE_URLapart before it reaches Bun. Whennew URLrejected the value, the refusal quoted the whole string back —DATABASE_URL is not a URL: "..."— andDATABASE_URLholds the database password. The string most likely to fail that parse is one with a stray character in the password, so the one line that reported the fault wrote the credential into the log.It now names the variable and the shape it expects, the way every other refusal in the same function already does (
names no host,names no database,... is not percent-encoded), and never echoes the value.Pre-existing; surfaced while reviewing #400 (which was careful not to leak, and contrasted with this sibling line).
Where it runs
Boundary and audit
Proof
server/tests/db-client-address.test.tsgains a test that a URL with a secret password and an invalid port is refused with a message that does not contain the password; the existing not-a-URL test is updated to the new wording.bun test server/tests/db-client-address.test.ts→ 11 pass, 0 fail.