If we are on the development server we must filter emails #501
No reviewers
Labels
No labels
Kestra
bug
enhancement
someday
subtask
☁️ api
🎛️ infrastructure
🐞 sentry
📆 2025 Season
📝 pages
allpicks
📝 pages
picks
📝 pages
standings
🚀 performance
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
johnsturgeon/tgfp-web!501
Loading…
Reference in a new issue
No description provided.
Delete branch "change-all-outgoing-email-s-on-dev-server-to-tgfp-us-500"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm just going to route all emails to tgfp.us
This is a small, self-contained change. I've reviewed the mailer logic, the config wiring, and the test setup.
Review
This PR adds a development-only safeguard that rewrites outbound email domains to a configurable redirect domain (
DEV_REDIRECT_EMAIL_DOMAIN), sparing the admin address, so a dev database can't accidentally spam real players. The logic is correct and the config/env wiring is complete; my only substantive concern is that the new code path has no test coverage.Worth fixing
No test exercises the new redirect path (
app/mailer.py:38-47). The existing suite runs underENVIRONMENT="testing"(tests/conftest.py:74), so_send'sif config.ENVIRONMENT == 'development'branch is never entered — the redirect, the admin-email exception, and the new log counts all ship untested. This is exactly the kind of "don't email real players" safety net that warrants a pinned test.tests/test_mailer.pyalready has abuilt_messagefixture that captures theMessageSchema; a test thatmonkeypatch.setattr(config, "ENVIRONMENT", "development")and assertsmessage.recipientswere rewritten (and thatTGFP_ADMIN_EMAILwas left intact) would cover it directly.DEV_REDIRECT_EMAIL_DOMAINis now required in every environment (app/config/config.py:85).get_config()reads it withos.environ[...], whichKeyErrors at startup if unset — including in production, where the value is never used. It is added toconfig/op.env, so a normal prod deploy is fine, but it's a required variable purely for a dev feature. Not blocking given op.env is the manifest, just worth being aware of.Nits
Local-part collisions in dev (
app/mailer.py:44). Two recipients that share a local part across different domains (e.g.john@gmail.comandjohn@yahoo.com) both collapse tojohn@<redirect>, so a dev run would send one of them a duplicate and the other nothing. Harmless in practice, but worth a mental note when eyeballing dev sends.Quote-style inconsistency (
app/mailer.py:39).'development'uses single quotes; the same literal is written"development"elsewhere (app/main.py:597). Cosmetic — neither pylint nor flake8 enforces this here.The
if/elsecould be a single comprehension, but the explicit loop is arguably clearer for a safety-critical branch, so I'd leave it.Nothing blocking — this is a sensible guardrail and the implementation matches the intent described in
docs/sample.env.