openai/codex-plugin-cc · error · Error

Missing value for --${rawKey}

Error message

Missing value for --${rawKey}

What it means

Thrown by parseArgs when a long option registered in config.valueOptions appears as the last token with no value. The parser first looks for an inline value via '--key=value', then falls back to the next argv token; if both are absent (nextValue === undefined) it cannot satisfy a value-bearing option. This is a usage/contract error, not a runtime fault.

Source

Thrown at plugins/codex/scripts/lib/args.mjs:39

    if (!token.startsWith("-") || token === "-") {
      positionals.push(token);
      continue;
    }

    if (token.startsWith("--")) {
      const [rawKey, inlineValue] = token.slice(2).split("=", 2);
      const key = aliasMap[rawKey] ?? rawKey;

      if (booleanOptions.has(key)) {
        options[key] = inlineValue === undefined ? true : inlineValue !== "false";
        continue;
      }

      if (valueOptions.has(key)) {
        const nextValue = inlineValue ?? argv[index + 1];
        if (nextValue === undefined) {
          throw new Error(`Missing value for --${rawKey}`);
        }
        options[key] = nextValue;
        if (inlineValue === undefined) {
          index += 1;
        }
        continue;
      }

      positionals.push(token);
      continue;
    }

    const shortKey = token.slice(1);
    const key = aliasMap[shortKey] ?? shortKey;

    if (booleanOptions.has(key)) {
      options[key] = true;
      continue;

View on GitHub (pinned to db52e28f4d)

Solutions

  1. Supply the value inline: '--model=gpt-5' or as the next token: '--model gpt-5'.
  2. If the option is genuinely optional, remove it from config.valueOptions or register it in config.booleanOptions instead.
  3. When building argv programmatically, assert each value-option token is followed by a non-flag value before calling parseArgs.
  4. If the flag was meant as a boolean switch, pass it through config.booleanOptions so '--flag' sets true.

Example fix

// before
parseArgs(['--model'], { valueOptions: ['model'] }) // throws

// after
parseArgs(['--model', 'gpt-5'], { valueOptions: ['model'] })
// or
parseArgs(['--model=gpt-5'], { valueOptions: ['model'] })
Defensive patterns

Strategy: validation

Validate before calling

// Validate value-options are satisfied before parsing.
function validateValueOptions(argv, valueOptions) {
  const set = new Set(valueOptions);
  for (let i = 0; i < argv.length; i += 1) {
    const t = argv[i];
    if (t.startsWith('--') && t !== '--') {
      const [rawKey, inline] = t.slice(2).split('=', 2);
      if (set.has(rawKey) && inline === undefined) {
        const next = argv[i + 1];
        if (next === undefined || next === '--' || next.startsWith('-')) {
          throw new Error(`Missing value for --${rawKey} (caught pre-parse)`);
        }
      }
    }
  }
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Invoking parseArgs(argv, config) where config.valueOptions contains a key K, and argv ends with '--K' (or '--K' is followed only by a '--' passthrough marker or another already-consumed token). Example: parseArgs(['--model'], { valueOptions: ['model'] }) or parseArgs(['--model','--'], {...}) where '--' flips passthrough mode.

Common situations: A user forgets the argument to a flag such as --model, --base, --source, or --threadName. Shell quoting bugs strip an empty value. A dynamically-built command string drops the trailing value during templating.

Related errors


AI-assisted analysis of openai/codex-plugin-cc@db52e28f4d (2026-08-13). Data as JSON: /api/errors/fe0d245cbda62699. Report an issue: GitHub.