fix(settings): fall back to local default when DATABASE_URL is empty - #5235
Merged
Merged
Conversation
getSettings()'s auto-init path used `envVars.DATABASE_URL ?? default`, so an explicitly-set but empty DATABASE_URL (e.g. a templated env var left unfilled) flowed through as an empty connection string instead of falling back to the documented local default. Every other env-fallback in this file (natsUrls right below it, and every field in resolve-config.ts) uses `||` for exactly this reason. Match that convention.
pedrofrxncx
enabled auto-merge (squash)
July 24, 2026 22:00
decocms Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
PR: #5235 fix(settings): fall back to local default when DATABASE_URL is empty Bump type: patch - decocms (apps/api/package.json): 4.126.1 -> 4.126.2 Deploy-Scope: server
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.
Bug found while auditing
apps/api/src/settings/for environment-fallback edge cases (a lot of similar??-vs-||bugs in this area were fixed in recent PRs like #5173, #5177, #5191, #5213, #5217).Failure scenario:
getSettings()'s child-process auto-init path (apps/api/src/settings/index.ts,initSettingsFromEnv) resolvesdatabaseUrlwithenvVars.DATABASE_URL ?? "postgresql://postgres:postgres@localhost:5432/postgres".??only falls back onnull/undefined— ifDATABASE_URLis explicitly set but empty (e.g. a templated deploy env var left unfilled), the empty string flows straight through as the connection string instead of falling back to the documented local default. The very next field in the same object (natsUrls) already uses||for this exact reason, and every field in the siblingresolve-config.tsfollows the same|| defaultconvention — this one line was the odd one out.Fix: change
??to||, matching the established convention.Regression test:
apps/api/src/settings/index.test.tssetsDATABASE_URL=""and assertsgetSettings().databaseUrlresolves to the local default. Verified this test fails on the old code (Received: "") and passes with the fix.To verify:
bun test apps/api/src/settings/index.test.tsChecks run locally:
bun run fmt,cd apps/api && bunx tsc --noEmit, and the targeted test file above (plus the fullresolve-config.test.tssuite, still 58/58 green). Full CI validates the rest.Summary by cubic
Fixes settings init to fall back to the local default database URL when
DATABASE_URLis set to an empty string. Switched??to||inapps/api/src/settings/index.tsand added a regression test to lock this behavior.Written for commit d5b9d35. Summary will update on new commits.