{"record":{"id":"943b98c2dd08b028","repo":"koala73/worldmonitor","slug":"backfillcanary250-resend-api-key-not-set-run-w","errorCode":null,"errorMessage":"[backfillCanary250] RESEND_API_KEY not set — run with the same env that hosts the canary segment.","messagePattern":"\\[backfillCanary250\\] RESEND_API_KEY not set — run with the same env that hosts the canary segment\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"convex/broadcast/backfillCanaryWaveStamps.ts","lineNumber":128,"sourceCode":" * Page Resend's `GET /contacts?segment_id=...` with cursor pagination\n * (`after=<contact-id>`) until exhausted, calling\n * `_stampWaveByNormalizedEmail` for each contact's email.\n *\n * Convex action time limit is 10 minutes; at ~244 contacts and one\n * Resend GET per ~100 plus one Convex mutation per contact, this\n * comfortably fits in well under a minute.\n *\n * All Resend addresses are normalized via the same `trim().toLowerCase()`\n * convention used at every write site — must match\n * `registrations.normalizedEmail` semantics or the join would silently\n * miss rows.\n */\nexport const backfillCanary250 = internalAction({\n  args: {},\n  handler: async (ctx): Promise<BackfillStats> => {\n    const apiKey = process.env.RESEND_API_KEY;\n    if (!apiKey) {\n      throw new Error(\n        \"[backfillCanary250] RESEND_API_KEY not set — run with the same env that hosts the canary segment.\",\n      );\n    }\n\n    if (!Number.isFinite(CANARY_SENT_AT_MS)) {\n      throw new Error(\n        \"[backfillCanary250] CANARY_SENT_AT_MS failed Date.parse — check the literal.\",\n      );\n    }\n\n    const stats: BackfillStats = {\n      fetched: 0,\n      stamped: 0,\n      alreadyStamped: 0,\n      notFound: 0,\n      failed: 0,\n    };\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/koala73/worldmonitor/blob/ffec79ac339946fd2d24e85845da5755dcaa534b/convex/broadcast/backfillCanaryWaveStamps.ts#L110-L146","documentation":"Thrown by the backfillCanary250 internal action when process.env.RESEND_API_KEY is unset. The action pages Resend's contact-listing API to stamp prior canary-wave rows, so it must run in an environment that has the Resend API key configured — the same env that hosts the canary segment.","triggerScenarios":"Invoking backfillCanary250 in an environment (local dev, CI, a fresh Convex deployment) where the RESEND_API_KEY environment variable is not set; running the backfill in a context that does not share env with the production Resend integration.","commonSituations":"Developer ran the action locally without .env.local; Convex env vars not propagated to the deployment; a new staging environment missing the Resend key; the key was rotated and the new value not deployed.","solutions":["Set RESEND_API_KEY in the Convex deployment environment: `npx convex env set RESEND_API_KEY=<value>`.","For local runs, ensure .env.local (or the local Convex env) has RESEND_API_KEY.","Confirm the key value matches the Resend account that hosts the canary segment."],"exampleFix":"// before — env missing\nawait backfillCanary250(ctx, {}); // RESEND_API_KEY not set\n// after — set env in Convex deployment first\n// $ npx convex env set RESEND_API_KEY re_xxx\nawait backfillCanary250(ctx, {});","handlingStrategy":"validation","validationCode":"if (!process.env.RESEND_API_KEY) {\n  throw new Error(\"Set RESEND_API_KEY in the Convex env before running backfillCanary250\");\n}\nawait backfillCanary250(ctx, {});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set RESEND_API_KEY via `npx convex env set` in every deployment environment that runs backfills.","Document the env requirement in the runbook for canary backfills.","Verify env presence in a preflight check before invoking the action."],"tags":["convex","broadcast","resend","env","config","backfill"],"backgroundTag":null,"analyzedSha":"ffec79ac339946fd2d24e85845da5755dcaa534b","analyzedAt":"2026-08-12T11:24:56.012Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}