{"record":{"id":"c5f0b01e30cc7ce1","repo":"Yeachan-Heo/oh-my-codex","slug":"missing-value-for-flag","errorCode":null,"errorMessage":"Missing value for ${flag}.","messagePattern":"Missing value for (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/autopilot.ts","lineNumber":34,"sourceCode":"  omx autopilot advance --to <ralplan|ultragoal> --handoff-json <json-or-path> [--session <id>] [--json]\n\nThe supervisor owns one session-scoped autopilot-state.json. Child stages remain\nsupervised phases; advance validates durable artifacts and cannot skip stages.\nCancel and state clear remain available through their normal exact-session paths.\n`;\n\ninterface AutopilotCommandDependencies {\n  cwd?: () => string;\n  stdout?: (line: string) => void;\n}\n\nfunction value(args: readonly string[], flag: string): string | undefined {\n  const inline = args.find((arg) => arg.startsWith(`${flag}=`));\n  if (inline) return inline.slice(flag.length + 1);\n  const index = args.indexOf(flag);\n  if (index < 0) return undefined;\n  const result = args[index + 1];\n  if (!result || result.startsWith('--')) throw new Error(`Missing value for ${flag}.`);\n  return result;\n}\n\nfunction positionalTask(args: readonly string[]): string {\n  const valueFlags = new Set(['--task', '--session', '--to', '--handoff-json']);\n  const words: string[] = [];\n  for (let i = 0; i < args.length; i += 1) {\n    if (valueFlags.has(args[i])) { i += 1; continue; }\n    if (!args[i].startsWith('--')) words.push(args[i]);\n  }\n  return words.join(' ').trim();\n}\n\nasync function jsonInput(raw: string): Promise<Record<string, unknown>> {\n  const text = raw.trim().startsWith('{') ? raw : await readFile(raw, 'utf-8');\n  const parsed = JSON.parse(text) as unknown;\n  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) throw new Error('--handoff-json must resolve to a JSON object.');\n  return parsed as Record<string, unknown>;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/autopilot.ts#L16-L52","documentation":"The autopilot arg parser supports both `--flag=value` and `--flag value` forms. In the two-token form, if the token after the flag is missing, empty, or is itself another `--flag`, the value is considered missing and the error names the flag that lacked a value.","triggerScenarios":"Calling autopilot with `--task --to alice` (value looks like another flag), `--task` as the last argument, or an empty inline value edge in `--session`/`--task`/`--to`/`--handoff-json`.","commonSituations":"Flag ordering mistakes; scripts conditionally appending a flag without its value; values that genuinely start with `--` (e.g. a task string beginning with dashes).","solutions":["Supply the value: `--task \"fix the bug\"` or inline `--task=\"fix the bug\"`","If the value legitimately starts with `--`, use the `--flag=value` inline form to disambiguate","Fix scripts so flags and values are appended as a pair, never conditionally one-sided"],"exampleFix":"# before\nomx autopilot --task --to alice\n# after\nomx autopilot --task=\"--to alice considered as text\" --to alice","handlingStrategy":"validation","validationCode":"function flagValue(args: string[], flag: string): string | undefined {\n  const i = args.indexOf(flag);\n  if (i < 0) return undefined;\n  const v = args[i + 1];\n  if (!v || v.startsWith('--')) throw new Error(`Missing value for ${flag}.`);\n  return v;\n}","typeGuard":null,"tryCatchPattern":"catch (e) { const m = /Missing value for (.+)\\./.exec(String(e)); if (m) { repromptForFlag(m[1]); } else throw e; }","preventionTips":["Prefer the --flag=value inline form for unambiguous parsing","Append flags and values as pairs in scripts","Quote values that may start with dashes"],"tags":["cli","argument-parsing","autopilot","missing-value"],"backgroundTag":"missing-flag-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}