koala73/worldmonitor · error · Error

[pickWaveAction] RESEND_API_KEY not set

Error message

[pickWaveAction] RESEND_API_KEY not set

What it means

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.

Source

Thrown at convex/broadcast/waveRuns.ts:698

});

export const pickWaveAction = internalAction({
  args: {
    waveLabel: v.string(),
    runId: v.string(),
    requestedCount: v.number(),
    batchSize: v.optional(v.number()),
    // Filter contacts whose locale (from `users.localePrimary` or email-TLD
    // heuristic fallback) is non-English. Filter runs INSIDE the registration
    // pagination loop, BEFORE reservoir sampling — sampling-then-filtering
    // would silently underfill (sample 1000, exclude 200, send 800 even
    // though thousands of eligible English contacts existed elsewhere).
    excludeNonEnglish: v.optional(v.boolean()),
  },
  handler: async (ctx, args): Promise<{ ok: boolean; reason?: string }> => {
    const apiKey = process.env.RESEND_API_KEY;
    if (!apiKey) {
      throw new Error("[pickWaveAction] RESEND_API_KEY not set");
    }
    if (!Number.isFinite(args.requestedCount) || args.requestedCount <= 0) {
      throw new Error(
        `[pickWaveAction] requestedCount must be a positive integer; got ${args.requestedCount}`,
      );
    }
    if (args.waveLabel.length === 0 || args.waveLabel.length > 64) {
      throw new Error("[pickWaveAction] waveLabel must be 1-64 chars");
    }
    const batchSize = args.batchSize ?? DEFAULT_BATCH_SIZE;
    const excludeNonEnglish = args.excludeNonEnglish === true;

    // Step 1: claim lease + insert waveRuns row.
    const claim: ClaimLeaseResult = await ctx.runMutation(
      internal.broadcast.waveRuns._claimWaveRunLease,
      {
        waveLabel: args.waveLabel,
        runId: args.runId,

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Set RESEND_API_KEY in the Convex dashboard environment variables and re-run the wave
  2. Include the env check in deployment smoke tests for broadcast operations
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at convex/broadcast/waveRuns.ts:698 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/ea28298f0c39b3b0. Report an issue: GitHub.