fix(compose): use DB_USER consistently — DB_USERNAME silently dropped operator overrides#142
Merged
Merged
Conversation
… operator overrides
`app/config/env.js` reads `process.env.DB_USER` (and `.env.example`
documents it). But `docker-compose.yml` and two README sections
referenced `DB_USERNAME`. The mismatch was silent and harmless on
defaults — both compose interpolation and the container's app fell
back to `"timetracker"` — but it meant an operator who set
`DB_USER=foo` in their `.env` got that value SILENTLY DROPPED by
docker-compose's `${DB_USERNAME:-timetracker}` interpolation, and
both Postgres and the app ended up on the default user instead.
The connection still worked (matching by coincidence), but the
operator's stated config never reached the container.
Replace every `DB_USERNAME` reference with `DB_USER`:
- docker-compose.yml (5 occurrences): POSTGRES_USER, the
pg_isready healthcheck, PGUSER for the setup service, and
the env passthroughs on the migrate + api services.
- tests/integration/README.md (1 occurrence): the env-var
export example in the manual integration-test recipe.
- README.md (1 occurrence): the same env-var export in the
quickstart for running integration tests.
Backward-compat note: anyone with an existing `.env` that set the
undocumented `DB_USERNAME` variable will need to rename it to
`DB_USER`. The CI workflow already uses `DB_USER` and continues to
work unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Closes #141.
Summary
app/config/env.jsreadsprocess.env.DB_USERand.env.exampledocumentsDB_USER=timetracker. Butdocker-compose.ymland two README sections referencedDB_USERNAME. The mismatch was silent on defaults (both sides fall back to"timetracker"), but meant an operator who setDB_USER=fooin their.envgot that value silently dropped by compose's${DB_USERNAME:-timetracker}interpolation — both Postgres and the app ended up on the default user, not the configured one.Replace every
DB_USERNAMEreference withDB_USER:docker-compose.yml— 5 occurrences (postgresPOSTGRES_USER,pg_isreadyhealthcheck,PGUSERon setup service, env passthrough on migrate + api)tests/integration/README.md— 1 occurrence in the env-var export exampleREADME.md— 1 occurrence in the integration-test quickstartBackward-compat note: anyone with an existing
.envthat set the undocumentedDB_USERNAMEwill need to rename it toDB_USER. The default-user path is unchanged.Test plan
npm run lint— cleannpm test— 515 passed, 15 skipped (no source code touched, so no test count change)grep -rEn 'DB_USERNAME' . --include='*.yml' --include='*.md'returns empty across tracked filesProudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/