{"record":{"id":"bab68e765eeb42ad","repo":"coleam00/Archon","slug":"result-error","errorCode":null,"errorMessage":"result.error","messagePattern":"result\\.error","errorType":"exception","errorClass":"WorkflowRunFailedError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":3213,"sourceCode":"    // Surface workflow result to Web UI as a result card (mirrors orchestrator.ts result message).\n    // Paused workflows are handled in the branch above and intentionally do not get a result card.\n    if ('summary' in result && result.summary) {\n      try {\n        await adapter.sendMessage(conversationId, result.summary, {\n          category: 'workflow_result',\n          segment: 'new',\n          workflowResult: { workflowName: workflow.name, runId: result.workflowRunId },\n        });\n      } catch (surfaceError) {\n        getLog().warn(\n          { err: surfaceError as Error, conversationId },\n          'cli.workflow_result_surface_failed'\n        );\n      }\n    }\n    console.log('\\nWorkflow completed successfully.');\n  } else {\n    throw new WorkflowRunFailedError(result.error, detachedProcessOwner);\n  }\n}\n\n/**\n * Run a specific workflow.\n *\n * A thin owner around the implementation: whatever the run does with its captured source,\n * the capture is either adopted by a run or reclaimed. The implementation has a dozen\n * ordinary ways out — unknown workflow, refused inputs, flag conflicts, a detached\n * dispatch — and asking each to remember a disposal call is how most of them did not.\n */\nexport async function workflowRunCommand(\n  cwd: string,\n  workflowName: string,\n  userMessage: string,\n  options: WorkflowRunOptions = {}\n): Promise<void> {\n  try {","sourceCodeStart":3195,"sourceCodeEnd":3231,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L3195-L3231","documentation":"When a workflow completes unsuccessfully, the CLI throws `WorkflowRunFailedError(result.error, detachedProcessOwner)` (packages/cli/src/utils/workflow-exit-code.ts:8), carrying the workflow's error string and the detached flag; `resolveCliExitCode` maps it to a distinct exit code (including DETACHED_RUN_FAILED_EXIT_CODE) so wrappers can detect failure programmatically.","triggerScenarios":"`executeWorkflow` returns `result.success === false`: a node failed, retries exhausted, a gate was rejected, or an infrastructure error failed the run — the CLI surfaces it as this typed error.","commonSituations":"A bash node exited non-zero; an AI node exhausted retries; a human gate was rejected; docker/network failure inside a node became a permanent run failure.","solutions":["Read the workflow's error text (from result.error, shown in output) and fix the underlying node-level cause.","Re-run the workflow after fixing; completed nodes are reused on resume where supported.","In detached mode, inspect the run-control status/log for the failed run before retrying.","Wrap invocations expecting possible failure: catch `WorkflowRunFailedError` and map its exit code via `resolveCliExitCode`."],"exampleFix":"// before\ntry { await runWorkflowCommand(...) } catch (e) { console.error(e) }\n// after\nimport { WorkflowRunFailedError, resolveCliExitCode } from '../utils/workflow-exit-code';\ntry {\n  await runWorkflowCommand(...);\n} catch (e) {\n  if (e instanceof WorkflowRunFailedError) {\n    console.error(`Workflow failed: ${e.message}`);\n    process.exitCode = resolveCliExitCode(e);\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isWorkflowRunFailedError(e: unknown): e is WorkflowRunFailedError {\n  return e instanceof WorkflowRunFailedError;\n}","tryCatchPattern":"try {\n  await runWorkflowCommand(...);\n} catch (e) {\n  if (isWorkflowRunFailedError(e)) {\n    console.error(`Workflow failed: ${e.message}`);\n    process.exitCode = resolveCliExitCode(e);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Inspect the workflow's reported error (node output) before re-running.","Fix failing node scripts/providers, then resume to reuse completed nodes.","Handle the detached-failure exit code distinctly in wrappers/CI.","Validate node inputs (paths, env vars) before the run to reduce node-level failures."],"tags":["workflow","exit-code","typed-error"],"backgroundTag":"workflow-run-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}