{"record":{"id":"53470ee1708d2026","repo":"coleam00/Archon","slug":"invalid-status-opts-status-valid-workfl","errorCode":null,"errorMessage":"Invalid --status '${opts.status}'. Valid: ${workflowRunStatusSchema.options.join(', ')}.","messagePattern":"Invalid --status '(.+?)'\\. Valid: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":3955,"sourceCode":"      console.log(\n        `  ${run.id.slice(0, 8)}  ${run.workflow_name}  (${formatAge(run.started_at)})  adopt: workflow run <name> --adopt ${run.id}`\n      );\n    }\n    console.log('');\n    return;\n  }\n\n  let statusFilter: WorkflowRunStatus | undefined;\n  if (opts.status) {\n    const parsed = workflowRunStatusSchema.safeParse(opts.status);\n    if (!parsed.success) {\n      const msg = `Invalid --status '${opts.status}'. Valid: ${workflowRunStatusSchema.options.join(', ')}.`;\n      // --json never throws — emit one parseable {ok:false} line (write-command contract).\n      if (opts.json) {\n        await writeJsonLine({ ok: false, error: msg });\n        return;\n      }\n      throw new Error(msg);\n    }\n    statusFilter = parsed.data;\n  }\n\n  // Scope to this project by exact registration first, then through the\n  // checkout's canonical repository path. This preserves an explicitly\n  // registered linked worktree while allowing another linked worktree to share\n  // its registered primary checkout. Ordinary clones remain unchanged (#2613).\n  // --all opts out of scoping. A lookup failure or an unregistered cwd both\n  // fall back to the global list — never a silent wrong-scope (the human path\n  // prints an explicit note below).\n  let codebase = null;\n  if (!opts.all) {\n    try {\n      codebase = await findCodebaseForCheckoutPath(cwd);\n    } catch (error) {\n      getLog().warn({ err: error as Error, cwd }, 'cli.workflow_runs_codebase_lookup_failed');\n    }","sourceCodeStart":3937,"sourceCodeEnd":3973,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L3937-L3973","documentation":"`archon workflow runs --status` validates its value against workflowRunStatusSchema before querying. An unrecognized status string is rejected with the list of valid schema options, and --json mode emits {ok:false} instead of throwing.","triggerScenarios":"`archon workflow runs --status typo` where the value is not one of workflowRunStatusSchema.options (e.g. 'fail', 'success', 'complete' instead of the schema's enum values).","commonSituations":"Hand-written shell scripts with hardcoded status names, status names changed between Archon versions, or copying status names from a different tool.","solutions":["Use a status listed in the error message verbatim (they come from workflowRunStatusSchema.options).","Run `archon workflow runs --status <valid>` after checking the schema/docs for current enum values.","In scripts, validate the status against the schema options (or a copied constant) before invoking the CLI."],"exampleFix":"// before\narchon workflow runs --status success\n// after\narchon workflow runs --status completed","handlingStrategy":"validation","validationCode":"const VALID=['pending','running','failed','completed','cancelled','awaiting_gate','waiting']; if (!VALID.includes(status)) throw new Error(`bad --status ${status}; use one of ${VALID.join(',')}`);","typeGuard":"type RunStatus = typeof workflowRunStatusSchema.options[number]; function isRunStatus(s: string): s is RunStatus { return (workflowRunStatusSchema.options as readonly string[]).includes(s); }","tryCatchPattern":"try { await runs({ status }); } catch (e) { if (String(e.message).startsWith('Invalid --status')) { console.error(e.message); process.exit(2); } throw e; }","preventionTips":["Import workflowRunStatusSchema (or its derived union type) instead of hardcoding status strings.","Derive allowed statuses from the schema options at call time so version changes surface at compile time.","Capture valid values from the error message itself, which enumerates schema options."],"tags":["cli","validation","workflow"],"backgroundTag":"invalid-enum-value","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}