Say which part of DATABASE_URL is not percent-encoded, instead of failing as URI error - #400
Merged
Merged
Conversation
…ling as URI error
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso and
tylerslaton
as code owners
September 6, 2026 12:13
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
# Conflicts: # CHANGELOG.md
davidmckayv
approved these changes
Sep 6, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Deep-reviewed against live code (correctness, governance, no vendor/secret/scale issues). Composed build+tests green. CHANGELOG/format rebase on CI-validated substance.
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
A
DATABASE_URLwhose password holds a%that starts no escape stops the server withwhich names neither the variable nor which part of it was wrong. It comes out of
addressOf, theone function whose entire job is to make a connection failure legible, and which answers every other
malformed address with a sentence saying what to fix:
new URLaccepts the string, so the failure lands two lines later ondecodeURIComponent, whichwas added in #384 alongside taking the address apart. Measured, on Bun 1.3.14:
A generated password is a common place to find a literal
%, and this is a startup failure with noretry and nothing in the message to search for.
decodePartwraps the three decodes and refuses with the same shape as its neighbours: which part,and that a literal
%must be written%25. A correctly encoded password decodes exactly as it did.I also moved the
maxdoc comment down ontocreateDatabase, where it belongs. It was alreadydetached — it sat above
addressOf's own doc block — and adding a function there would have made itread as documentation for the new one.
Where it runs
startup.
with the same sentence. Every replica reads the same
DATABASE_URL, so this is a change ofmessage, not of behaviour that can differ per process.
Boundary and audit
the database exists, so there is nowhere to write a row to and nothing has yet acted.
Changelog
CHANGELOG.mdunderUnreleased.Tests
Four in
server/tests/db-client-address.test.ts, alongside the refusals already enumerated there:%is refused, naming the passwordp%40ssstill decodes top@ss, so a correctly written password is untouchedAgainst
mainthe first three fail; the fourth passes before and after and is there as theregression guard.
How I tested
Windows 11, Bun 1.3.14.
bun test server/tests/db-client-address.test.tsis 9 passed, 1 failed —the failure is
connection parameters on the URL > survive…, which opens a real socket to Postgresand fails identically on
mainon this machine, where no database is running.bun run --filter server typecheckandbunx biome checkare clean.