{"record":{"id":"9a3f6384a2c1749e","repo":"Yeachan-Heo/oh-my-codex","slug":"missing-value-for-flag-9a3f63","errorCode":null,"errorMessage":"Missing value for ${flag}.","messagePattern":"Missing value for (.+?)\\.","errorType":"exception","errorClass":"MissionCommandError","httpStatus":null,"severity":"error","filePath":"src/cli/mission.ts","lineNumber":134,"sourceCode":"      source_line: index + 1,\n      status: \"pending\",\n    });\n  }\n  return tasks;\n}\n\nfunction slugify(value: string): string {\n  const slug = value\n    .toLowerCase()\n    .replace(/[^a-z0-9]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\")\n    .slice(0, 80);\n  return slug || \"mission\";\n}\n\nfunction readValue(args: readonly string[], index: number, flag: string): string {\n  const value = args[index + 1];\n  if (!value || value.startsWith(\"--\")) throw new MissionCommandError(`Missing value for ${flag}.`);\n  return value;\n}\n\nfunction parseMissionArgs(args: string[]): ParsedMissionArgs {\n  let rest = [...args];\n  const command = rest[0];\n  if (command === \"help\" || command === \"--help\" || command === \"-h\") {\n    throw new MissionCommandError(MISSION_HELP);\n  }\n\n  let action: MissionAction = \"run\";\n  if (command === \"run\") rest = rest.slice(1);\n  else if (command === \"plan\") {\n    action = \"plan\";\n    rest = rest.slice(1);\n  } else if (command === \"status\" || command === \"mark\" || command === \"resume\" || command === \"rerun\") {\n    action = command;\n    rest = rest.slice(1);","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/mission.ts#L116-L152","documentation":"readValue fetches the token after a mission CLI flag; if there is no next token, or the next token itself starts with '--' (i.e. looks like another flag, not a value), it throws MissionCommandError `Missing value for <flag>.`","triggerScenarios":"`mission --title` at end of argv, or `mission --title --tags x` where the would-be value position is occupied by another flag. Any flag consumed via readValue with a missing/flag-like follower triggers this.","commonSituations":"Omitting a value for an optional-looking flag; flags whose values legitimately start with '--' (rare); script argv arrays with empty/unset expansions removed by the shell; reordered flags during refactors.","solutions":["Supply the value immediately after the flag: --title \"My Mission\"","If the value genuinely starts with '--', escape or restructure (e.g. read from env/stdin) since the parser treats it as a flag","Guard script variables: use \"${VAR:?required}\" so empty values fail loudly at expansion, not inside the CLI"],"exampleFix":"# before\nmycli mission create --title\n\n# after\nmycli mission create --title \"Nightly audit\"","handlingStrategy":"validation","validationCode":"function assertFlagValue(args: string[], flag: string) {\n  const i = args.indexOf(flag);\n  if (i !== -1 && (i + 1 >= args.length || args[i + 1].startsWith('--'))) {\n    console.error(`Missing value for ${flag}`);\n    process.exit(2);\n  }\n}\n['--title', '--tags'].forEach((f) => assertFlagValue(argv, f));","typeGuard":"function hasFlagValue(args: readonly string[], flag: string): boolean {\n  const i = args.indexOf(flag);\n  return i !== -1 && i + 1 < args.length && !args[i + 1].startsWith('--');\n}","tryCatchPattern":"try { await missionCommand(argv); }\ncatch (e) {\n  if (e instanceof MissionCommandError && /Missing value for/.test(e.message)) { console.error(e.message); printMissionUsage(); process.exit(2); }\n  throw e;\n}","preventionTips":["Always pair value-flags with an explicit quoted value","Use \"${VAR:?required}\" in shell scripts to fail on empty values"],"tags":["cli","missing-argument","argument-parsing","mission"],"backgroundTag":"missing-cli-option-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}