koala73/worldmonitor · error · Error

[_markPickComplete] no run ${args.runId}

Error message

[_markPickComplete] no run ${args.runId}

What it means

Thrown by _markPickComplete when no waveRuns row matches the provided runId. Like _recordPoolFilterStats, this indicates the run row is missing — the caller (pickWaveAction) should only call this after a successful pick phase on a run it already claimed. The row is created by _claimWaveRunLease at the start of the pipeline.

Source

Thrown at convex/broadcast/waveRuns.ts:602

});

/**
 * Transition a `picking`-status run to `segment-created` after pickWaveAction
 * has finished sampling, persisting, and creating the Resend segment.
 */
export const _markPickComplete = internalMutation({
  args: {
    runId: v.string(),
    segmentId: v.string(),
    totalCount: v.number(),
    underfilled: v.boolean(),
  },
  handler: async (ctx, args) => {
    const run = await ctx.db
      .query("waveRuns")
      .withIndex("by_runId", (q) => q.eq("runId", args.runId))
      .unique();
    if (!run) throw new Error(`[_markPickComplete] no run ${args.runId}`);
    if (run.status !== "picking") {
      throw new Error(
        `[_markPickComplete] run ${args.runId} is ${run.status}, expected picking`,
      );
    }
    const now = Date.now();
    await ctx.db.patch(run._id, {
      status: "segment-created",
      segmentId: args.segmentId,
      totalCount: args.totalCount,
      underfilled: args.underfilled,
      updatedAt: now,
    });
    return { ok: true };
  },
});

/**

View on GitHub (pinned to ffec79ac33)

Solutions

  1. Verify the runId passed to _markPickComplete matches the runId from _claimWaveRunLease in the same pickWaveAction invocation.
  2. Check whether discardWaveRun removed the row — if so, treat the run as cancelled and stop the pipeline.
  3. In tests, insert a waveRuns row with status 'picking' before calling _markPickComplete.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: pickWaveAction calls _markPickComplete with a runId whose row was deleted mid-flight (discardWaveRun or manual DB delete). The runId passed does not match the one returned by _claimWaveRunLease. A test calls _markPickComplete without first creating the run row.

Common situations: The operator discarded the wave run while pickWaveAction was still executing. A developer refactored pickWaveAction and introduced a runId mismatch. Parallel or replayed scheduled actions reference a stale runId.

Related errors


AI-assisted analysis of koala73/worldmonitor@ffec79ac33 (2026-08-12). Data as JSON: /api/errors/16a2cf93adbb2493. Report an issue: GitHub.