Repository navigation
fix: diagnose missing Resend on alert-rules evaluator (TT-010 emails) - #693
Merged
Merged
Conversation
Scheduled alert emails run in the evaluator process, not the API. Log email_not_configured without secrets, include email availability on each sweep, and document the required Railway env vars. Co-authored-by: Sanja Malovic <[email protected]>
TELEMETRY_EMAIL_FROM alone is required with RESEND_API_KEY. Email links read TELEMETRY_DASHBOARD_ORIGIN only; DASHBOARD_ORIGIN is unused there. Co-authored-by: Sanja Malovic <[email protected]>
unjica
marked this pull request as ready for review
September 25, 2026 19:35
This was referenced Sep 25, 2026
Merged
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.
Base branch:
developSummary
TT-010 remaining failure: scheduled rules create alert events and in-app notifications, but send 0 emails, while ingest-path emails work.
Verified against current production code (and live Railway vars)
Evaluator currently has:
DATABASE_URL,RESEND_API_KEY,DASHBOARD_ORIGIN.Missing:
TELEMETRY_EMAIL_FROM,NODE_ENV. NoTELEMETRY_DASHBOARD_ORIGIN.Missing
TELEMETRY_EMAIL_FROMalone explains 0/10 emails.isTransactionalEmailConfigured()requires bothRESEND_API_KEYandTELEMETRY_EMAIL_FROM. With only the API key set,sendTransactionalEmaildoes not call Resend.Email links read
TELEMETRY_DASHBOARD_ORIGINonly.dashboardOriginOrNull()/resolveDashboardOrigin()useprocess.env.TELEMETRY_DASHBOARD_ORIGIN. They do not readDASHBOARD_ORIGIN(that name is for API CORS). Having onlyDASHBOARD_ORIGINon the evaluator does not set email link bases.Unset
NODE_ENV:NODE_ENV !== "production"is true, so when Resend is incomplete the code takes the non-production branch (devLogged: true), which can keep aNotificationEmailLogclaim without sending mail. Still 0 emails; setNODE_ENV=productionso missing config fails clearly.Add/copy onto the evaluator (manual; not done in this PR):
TELEMETRY_EMAIL_FROM(copy from API) — required to sendTELEMETRY_DASHBOARD_ORIGIN(same URL as API / as the existingDASHBOARD_ORIGINvalue) — for absolute linksNODE_ENV=productionDATABASE_URLandRESEND_API_KEYDASHBOARD_ORIGINon the evaluator is unused by the email path; optional to leave or removeCode hardening (this PR)
error: "email_not_configured"+ one-time JSON warn (env names only)email: "configured" | "unavailable"TELEMETRY_EMAIL_FROM,TELEMETRY_DASHBOARD_ORIGIN≠DASHBOARD_ORIGIN)Cooldown / dedupe / evaluation unchanged. No deploy. No Railway changes in this PR.
How to test
pnpm --filter api test -- src/lib/email.test.ts src/jobs/alert-rules-evaluator.test.ts src/lib/dashboard-origin.test.ts src/lib/notification-email-dispatch.test.ts