{"record":{"id":"c56166ea4ae7bdb5","repo":"koala73/worldmonitor","slug":"markfinalizefailed-no-run-runid","errorCode":null,"errorMessage":"[_markFinalizeFailed] no run ${runId}","messagePattern":"\\[_markFinalizeFailed\\] no run (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"convex/broadcast/waveRuns.ts","lineNumber":1340,"sourceCode":" * finalize's clean state with `failureSubstatus='send-broadcast-failed'`,\n * and a subsequent operator `markFinalizeRecovered` would re-advance the\n * tier a second time.\n */\nexport const _markFinalizeFailed = internalMutation({\n  args: {\n    runId: v.string(),\n    substatus: v.union(\n      v.literal(\"create-broadcast-failed\"),\n      v.literal(\"send-broadcast-failed\"),\n    ),\n    error: v.string(),\n  },\n  handler: async (ctx, { runId, substatus, error }) => {\n    const run = await ctx.db\n      .query(\"waveRuns\")\n      .withIndex(\"by_runId\", (q) => q.eq(\"runId\", runId))\n      .unique();\n    if (!run) throw new Error(`[_markFinalizeFailed] no run ${runId}`);\n\n    // Terminal-status CAS. If a concurrent finalize already committed\n    // status='sent', this is a duplicate-finalize loser whose Resend\n    // 422-already-sent error landed it here. Treat as no-op success — the\n    // winner's state is correct; we should not overwrite it.\n    if (run.status === \"sent\") {\n      return { ok: false as const, reason: \"already-sent\" as const };\n    }\n    // Defensive: if already in a failed-with-different-substatus state,\n    // refuse to overwrite. Operator's existing recovery routing depends\n    // on the original substatus.\n    if (\n      run.status === \"failed\" &&\n      run.failureSubstatus !== undefined &&\n      run.failureSubstatus !== substatus\n    ) {\n      return {\n        ok: false as const,","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/convex/broadcast/waveRuns.ts#L1322-L1358","documentation":"Internal invariant guard in _markFinalizeFailed: no waveRuns row exists for the supplied runId. The failure status (create-broadcast-failed / send-broadcast-failed) cannot be recorded because the run record is missing, so the failure must be tracked manually.","triggerScenarios":"Thrown at convex/broadcast/waveRuns.ts:1340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the Resend dashboard for orphaned broadcasts or segments from the failed run and clean up manually","Fix the caller so finalize failure recording uses the same runId that claimed the run"],"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-14T00:17:10.932Z"}