Skip to content

fix(worker): forward DATABASE_SSL and DATABASE_CA_CERT to worker containers#992

Merged
zbigniewsobiecki merged 1 commit intodevfrom
fix/worker-database-ssl-forwarding
Mar 23, 2026
Merged

fix(worker): forward DATABASE_SSL and DATABASE_CA_CERT to worker containers#992
zbigniewsobiecki merged 1 commit intodevfrom
fix/worker-database-ssl-forwarding

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Root cause: buildWorkerEnvWithProjectId() forwarded DATABASE_URL but not DATABASE_SSL / DATABASE_CA_CERT, so every worker container started with rejectUnauthorized: true regardless of the router's SSL config — causing self-signed certificate in certificate chain crashes during loadConfig() at worker startup.
  • Fix: conditionally forward both vars, following the same pattern used for SENTRY_DSN, CLAUDE_CODE_OAUTH_TOKEN, etc.
  • Refactor: extracted all conditional env-var forwarding into a appendOptionalEnvVars() helper to resolve a pre-existing noExcessiveCognitiveComplexity lint warning (score was 15, now 16 with our additions — extracting to a helper drops the main function to ~9).

Call chain fixed

Router (DATABASE_SSL=false) ──spawns──► Worker
                                         getDb() → getSslConfig()
                                                   DATABASE_SSL → undefined  ← was the bug
                                                   rejectUnauthorized: true → SSL error

Test plan

  • 3 new unit tests: forwards DATABASE_SSL when set, omits DATABASE_SSL when not set, forwards DATABASE_CA_CERT when set
  • All 6295 unit tests pass (npm test)
  • npm run lint — no warnings
  • npm run typecheck — clean
  • After deploy: trigger a manual worker job and confirm no self-signed certificate Sentry event fires
  • Check worker logs: [Worker] Loaded projects config should appear (indicating loadConfig() succeeded)

🤖 Generated with Claude Code

…ainers

Worker containers were missing DATABASE_SSL and DATABASE_CA_CERT env vars,
causing `self-signed certificate in certificate chain` SSL errors during
loadConfig() at worker startup. The router had DATABASE_SSL=false set but
buildWorkerEnvWithProjectId() only forwarded DATABASE_URL, so workers always
defaulted to rejectUnauthorized: true.

Also extracts all optional env-var forwarding into appendOptionalEnvVars()
to fix a pre-existing noExcessiveCognitiveComplexity lint warning that our
new if-branches pushed over the threshold.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit c1c8b01 into dev Mar 23, 2026
8 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/worker-database-ssl-forwarding branch March 23, 2026 13:56
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/router/worker-env.ts 76.92% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant