Repository navigation
fix(mail): validate SMTP_URL, isolate mailer from DB, guided SMTP setup - #12
Merged
Merged
Conversation
… setup A malformed SMTP_URL (`smtps://user:pass@://gmail.com`) made nodemailer throw "Invalid URL" while the composition root was built. Because db, blobs and mailer were built in one promise, every Firestore-backed page and /api/health failed with 503/500, and the error object (incl. the password) ended up in the logs. - config: SMTP_URL is validated at startup (smtp/smtps + real hostname); the error message never echoes the value - container: mailer is built separately, so a broken mail setup can no longer take the database down; failed builds are no longer cached - smtp adapter: transport errors are rethrown without the URL - bootstrap: SMTP is entered as host/port/user (visible) + password (hidden) and the URL is assembled and encoded by the script; a stored malformed SMTP_URL is detected and re-entered or removed - tests: isValidSmtpUrl unit tests, dry-run scenario for a broken secret - docs (de/en): validation note, Gmail example, guided SMTP step Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcqxZNX1wgX8w3T7xRWFvZ
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.
Problem
On the first real Firebase deployment,
/api/healthreturned 503 and every Firestore-backed page returned 500, withTypeError: Invalid URL. The cause was a malformedSMTP_URLin theWAYFARE_ENVsecret (the host was missing:…@://gmail.com):input, ended up in Cloud Logging.Changes
src/server/config.ts:SMTP_URLis validated at startup (isValidSmtpUrl:smtp:/smtps:plus a real hostname). The error message never echoes the value.src/server/container.ts: the mailer is now its own lazy singleton, so a broken mail setup can no longer take the DB down. A failed build is no longer cached.src/server/adapters/mail/smtp.ts: transport errors are rethrown without the URL.scripts/firebase-bootstrap.sh:SMTP_URLalready stored in the secret is detected; you can re-enter it interactively, and with--yesit is removed.isValidSmtpUrl.badsmtpchecks detection, removal, the new secret version, and that the password is never printed.configuration.md: validation note.mail.md: Gmail example.firebase.md: guided SMTP step.Checks
npm run typecheck && npm run lint && npm test: 280 passed, 23 skipped.npm run test:integration: 63 passed.bash scripts/test/bootstrap-dry-run.sh: ALL CHECKS PASSED.Generated by Claude Code