Skip to content

fix: diagnose missing Resend on alert-rules evaluator (TT-010 emails) - #693

Merged
cursor[bot] merged 2 commits into
developfrom
cursor/alert-evaluator-email-config-f4fb
Sep 25, 2026
Merged

cursor[bot] merged 2 commits into
developfrom
cursor/alert-evaluator-email-config-f4fb

Conversation

@unjica

@unjica unjica commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Base branch: develop

Summary

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. No TELEMETRY_DASHBOARD_ORIGIN.

  1. Missing TELEMETRY_EMAIL_FROM alone explains 0/10 emails.
    isTransactionalEmailConfigured() requires both RESEND_API_KEY and TELEMETRY_EMAIL_FROM. With only the API key set, sendTransactionalEmail does not call Resend.

  2. Email links read TELEMETRY_DASHBOARD_ORIGIN only.
    dashboardOriginOrNull() / resolveDashboardOrigin() use process.env.TELEMETRY_DASHBOARD_ORIGIN. They do not read DASHBOARD_ORIGIN (that name is for API CORS). Having only DASHBOARD_ORIGIN on the evaluator does not set email link bases.

  3. 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 a NotificationEmailLog claim without sending mail. Still 0 emails; set NODE_ENV=production so missing config fails clearly.

  4. Add/copy onto the evaluator (manual; not done in this PR):

    • Add TELEMETRY_EMAIL_FROM (copy from API) — required to send
    • Add TELEMETRY_DASHBOARD_ORIGIN (same URL as API / as the existing DASHBOARD_ORIGIN value) — for absolute links
    • Add NODE_ENV=production
    • Keep existing DATABASE_URL and RESEND_API_KEY
    • DASHBOARD_ORIGIN on the evaluator is unused by the email path; optional to leave or remove

Code hardening (this PR)

  • error: "email_not_configured" + one-time JSON warn (env names only)
  • Notification send failures logged when the dedupe claim is released
  • Sweep log includes email: "configured" | "unavailable"
  • Docs name the correct variables (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
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 25, 2026 19:29
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
unjica marked this pull request as ready for review September 25, 2026 19:35
@cursor
cursor Bot merged commit a89aaee into develop Sep 25, 2026
9 checks passed
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.

2 participants