Refuse a DATABASE_URL with a port of zero at start-up - #485
Merged
davidmckayv merged 2 commits intoSep 11, 2026
Conversation
Ayush7614
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 11, 2026 09:57
davidmckayv
approved these changes
Sep 11, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Deep-reviewed clean (validation, no secret leak, fail-closed, agrees with existing layers). CI green.
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
postgres://…:0/…parsed throughnew URLas port"0"and travelled intonew SQL({ port: 0 })as0. Boot succeeded and every query then failed against a port nothing listens on. Ports outside 1-65535 are now refused at start-up with a sentence namingDATABASE_URL, before a socket is ever opened.new URLalready rejects:65536and above, so:0was the hole.Verified with
bun -e::0yields port"0",:65536/:99999throw innew URL, empty yields""(default 5432 unchanged).Where it runs
OpenBot is deployed as several server processes behind a load balancer, serving a whole company. Consecutive requests from the same person reach different processes, and the process that answered a WebSocket upgrade is rarely the one that answers the next call on that conversation.
Boundary and audit
Changelog
CHANGELOG.mdunderUnreleased: port-zero refusal entry.Proof
bun test server/tests/db-client-address.test.ts -t "port of zero": 1 pass.bun test server/tests/db-client-address.test.ts: 11 pass, 1 fail — the 1 failure is the pre-existingpg_stat_activityintegration test needing a live Postgres with anopenbotrole (role openbot does not existlocally); CI provides the database.bun run format:check: clean.bun run lint: clean.bun run typecheck: server and worker pass; app fails on pre-existing missingembla-carousel-reacttypes, identical on clean upstream main (verified viagit stash).