{"record":{"id":"ea28298f0c39b3b0","repo":"koala73/worldmonitor","slug":"pickwaveaction-resend-api-key-not-set","errorCode":null,"errorMessage":"[pickWaveAction] RESEND_API_KEY not set","messagePattern":"\\[pickWaveAction\\] RESEND_API_KEY not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"convex/broadcast/waveRuns.ts","lineNumber":698,"sourceCode":"});\n\nexport const pickWaveAction = internalAction({\n  args: {\n    waveLabel: v.string(),\n    runId: v.string(),\n    requestedCount: v.number(),\n    batchSize: v.optional(v.number()),\n    // Filter contacts whose locale (from `users.localePrimary` or email-TLD\n    // heuristic fallback) is non-English. Filter runs INSIDE the registration\n    // pagination loop, BEFORE reservoir sampling — sampling-then-filtering\n    // would silently underfill (sample 1000, exclude 200, send 800 even\n    // though thousands of eligible English contacts existed elsewhere).\n    excludeNonEnglish: v.optional(v.boolean()),\n  },\n  handler: async (ctx, args): Promise<{ ok: boolean; reason?: string }> => {\n    const apiKey = process.env.RESEND_API_KEY;\n    if (!apiKey) {\n      throw new Error(\"[pickWaveAction] RESEND_API_KEY not set\");\n    }\n    if (!Number.isFinite(args.requestedCount) || args.requestedCount <= 0) {\n      throw new Error(\n        `[pickWaveAction] requestedCount must be a positive integer; got ${args.requestedCount}`,\n      );\n    }\n    if (args.waveLabel.length === 0 || args.waveLabel.length > 64) {\n      throw new Error(\"[pickWaveAction] waveLabel must be 1-64 chars\");\n    }\n    const batchSize = args.batchSize ?? DEFAULT_BATCH_SIZE;\n    const excludeNonEnglish = args.excludeNonEnglish === true;\n\n    // Step 1: claim lease + insert waveRuns row.\n    const claim: ClaimLeaseResult = await ctx.runMutation(\n      internal.broadcast.waveRuns._claimWaveRunLease,\n      {\n        waveLabel: args.waveLabel,\n        runId: args.runId,","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/convex/broadcast/waveRuns.ts#L680-L716","documentation":"Configuration gate at the top of pickWaveAction: process.env.RESEND_API_KEY is unset on the Convex deployment. The action needs Resend to create the wave segment, so it fails fast before claiming a lease or sampling contacts.","triggerScenarios":"Thrown at convex/broadcast/waveRuns.ts:698 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set RESEND_API_KEY in the Convex dashboard environment variables and re-run the wave","Include the env check in deployment smoke tests for broadcast operations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}