{"record":{"id":"02e5c8035a9067fd","repo":"coleam00/Archon","slug":"failed-to-resolve-approval-gate-err-message","errorCode":null,"errorMessage":"Failed to resolve approval gate: ${err.message}","messagePattern":"Failed to resolve approval gate: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":270,"sourceCode":"    return await getDatabase().withTransaction(async query => {\n      const result = await query(\n        `UPDATE remote_agent_workflow_runs\n         SET metadata = ${dialect.jsonMerge('metadata', 2)}\n         WHERE id = $1 AND ${unresolvedGateClause()}`,\n        [id, JSON.stringify(metadata)]\n      );\n      const resolved = (result.rowCount ?? 0) > 0;\n      if (resolved) {\n        for (const event of events) {\n          await insertWorkflowEvent(query, { workflow_run_id: id, ...event });\n        }\n      }\n      return { resolved };\n    });\n  } catch (error) {\n    const err = error as Error;\n    getLog().error({ err, workflowRunId: id }, 'db.workflow_run_resolve_gate_failed');\n    throw new Error(`Failed to resolve approval gate: ${err.message}`);\n  }\n}\n\n/**\n * Atomically cancel a paused approval gate (compare-and-swap).\n *\n * The reject sibling of resolveApprovalGate for the outcomes that TERMINATE the\n * run (no on_reject prompt, or the attempt cap reached): it flips the run\n * paused→'cancelled' in a SINGLE conditional UPDATE, guarded on the SAME\n * open-gate predicate. Doing it in one statement (instead of stamp-resolution +\n * separate cancelWorkflowRun) means there is never an intermediate\n * resolved-but-not-cancelled state that a failed second write could strand — a\n * reject retry could not self-heal past the fast-path gate guard. No `resolved`\n * marker is written: that marker only matters for the stay-paused rework path,\n * and the rejection reason is preserved in the approval_received event.\n *\n * Writes `workflow_cancelled` itself (#2906) rather than trusting the caller to\n * pass it: this is a terminal status write, and every other terminal writer here","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L252-L288","documentation":"Error \"Failed to resolve approval gate: ${err.message}\" thrown in coleam00/Archon.","triggerScenarios":"Thrown at packages/core/src/db/workflows.ts:270 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}