{"record":{"id":"7065684da454de4f","repo":"coleam00/Archon","slug":"adopt-supersedes-requires-a-run-id","errorCode":null,"errorMessage":"--adopt/--supersedes requires a run id.","messagePattern":"--adopt/--supersedes requires a run id\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2316,"sourceCode":"  // Set when the adopt lane executes inside a checkout whose `.archon` may differ from\n  // this process's cwd — the trigger for recaptureForLane once the path is final.\n  let adoptLaneRunsIsolatedCheckout = false;\n  if (options.adoptRunId !== undefined || options.supersedesRunId !== undefined) {\n    if (!codebase) {\n      throw new Error(\n        'Cannot resolve the project for --adopt/--supersedes. Run from the project checkout and try again.'\n      );\n    }\n    // Narrowed by construction: the flag-conflict gate above guarantees exactly\n    // one of the two ids is present.\n    if (options.adoptRunId !== undefined) {\n      continuationMode = 'adopt';\n      adoptedFromRunId = await resolveRunIdArg(options.adoptRunId, cwd, false, codebase.id);\n    } else if (options.supersedesRunId !== undefined) {\n      continuationMode = 'supersede';\n      adoptedFromRunId = await resolveRunIdArg(options.supersedesRunId, cwd, false, codebase.id);\n    } else {\n      throw new Error('--adopt/--supersedes requires a run id.');\n    }\n\n    if (continuationMode === 'adopt') {\n      const { adoptedRun, lane } = await resolveWorkflowAdoption({\n        adoptedRunId: adoptedFromRunId,\n        codebaseId: codebase.id,\n        codebasePath: codebase.default_cwd,\n        codebaseKind: codebase.kind,\n        containerRequested: options.container === true,\n      });\n      if (lane.kind === 'reuse-worktree') {\n        workingCwd = lane.workingPath;\n        isolationEnvId = lane.envId;\n        adoptLaneRunsIsolatedCheckout = true;\n        // The reuse lane IS the isolation: run in the inherited worktree as-is.\n        // Leaving wantsIsolation set would fall through to worktree creation below\n        // and silently cut a fresh worktree from base over the inherited one.\n        wantsIsolation = false;","sourceCodeStart":2298,"sourceCodeEnd":2334,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2298-L2334","documentation":"Defensive guard on the --adopt/--supersedes continuation flags: continuation requires exactly one run id, and if neither option is set after the earlier resolution steps, the CLI throws this error. In practice the outer `if` makes it nearly unreachable — it exists so the type system can narrow options.adoptRunId/options.supersedesRunId to defined values.","triggerScenarios":"Programmatic invocation where the adopt/supersedes options object is constructed without either run id (both undefined) but some related flag skips the outer gate; effectively unreachable through normal CLI parsing of --adopt/--supersedes.","commonSituations":"Scripts or wrappers that build the options object dynamically and forget to pass the run id value, or pass an empty value that parseArgs dropped.","solutions":["Pass a run id: `archon workflow run <flow> --adopt <runId>` or `--supersedes <runId>`.","Check the wrapper/script constructing the command for a dropped or empty argument.","Use `archon workflow get <id>` to confirm the run id you intend to continue exists."],"exampleFix":"// before\narchon workflow run my-flow --adopt   # flag present but no id\n// after\narchon workflow run my-flow --adopt 7f3c9e2a-...","handlingStrategy":"validation","validationCode":"const adoptId = flags['adopt'] ?? flags['supersedes'];\nif (!adoptId) {\n  throw new Error('--adopt/--supersedes requires a run id, e.g. --adopt <runId>.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await spawn('archon', ['workflow', 'run', flow, '--adopt', runId]);\n} catch (e) {\n  if (String(e).includes('requires a run id')) {\n    console.error('Wrapper dropped the run id argument; check your script argv construction.');\n  } else throw e;\n}","preventionTips":["Always pass an explicit run id with --adopt/--supersedes.","Validate flag values in wrapper scripts before spawning the CLI.","Fetch the id from `archon workflow get` output programmatically, not by hand."],"tags":["cli","argument-validation","continuation"],"backgroundTag":"missing-required-argument","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}