Yeachan-Heo/oh-my-codex · error · MissionCommandError

Missing value for ${flag}.

Error message

Missing value for ${flag}.

What it means

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>.`

Source

Thrown at src/cli/mission.ts:134

      source_line: index + 1,
      status: "pending",
    });
  }
  return tasks;
}

function slugify(value: string): string {
  const slug = value
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, "-")
    .replace(/^-+|-+$/g, "")
    .slice(0, 80);
  return slug || "mission";
}

function readValue(args: readonly string[], index: number, flag: string): string {
  const value = args[index + 1];
  if (!value || value.startsWith("--")) throw new MissionCommandError(`Missing value for ${flag}.`);
  return value;
}

function parseMissionArgs(args: string[]): ParsedMissionArgs {
  let rest = [...args];
  const command = rest[0];
  if (command === "help" || command === "--help" || command === "-h") {
    throw new MissionCommandError(MISSION_HELP);
  }

  let action: MissionAction = "run";
  if (command === "run") rest = rest.slice(1);
  else if (command === "plan") {
    action = "plan";
    rest = rest.slice(1);
  } else if (command === "status" || command === "mark" || command === "resume" || command === "rerun") {
    action = command;
    rest = rest.slice(1);

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply the value immediately after the flag: --title "My Mission"
  2. If the value genuinely starts with '--', escape or restructure (e.g. read from env/stdin) since the parser treats it as a flag
  3. Guard script variables: use "${VAR:?required}" so empty values fail loudly at expansion, not inside the CLI

Example fix

# before
mycli mission create --title

# after
mycli mission create --title "Nightly audit"
Defensive patterns

Strategy: validation

Validate before calling

function assertFlagValue(args: string[], flag: string) {
  const i = args.indexOf(flag);
  if (i !== -1 && (i + 1 >= args.length || args[i + 1].startsWith('--'))) {
    console.error(`Missing value for ${flag}`);
    process.exit(2);
  }
}
['--title', '--tags'].forEach((f) => assertFlagValue(argv, f));

Type guard

function hasFlagValue(args: readonly string[], flag: string): boolean {
  const i = args.indexOf(flag);
  return i !== -1 && i + 1 < args.length && !args[i + 1].startsWith('--');
}

Try / catch

try { await missionCommand(argv); }
catch (e) {
  if (e instanceof MissionCommandError && /Missing value for/.test(e.message)) { console.error(e.message); printMissionUsage(); process.exit(2); }
  throw e;
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/9a3f6384a2c1749e. Report an issue: GitHub.