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

${flag} requires a value

Error message

${flag} requires a value

What it means

A value-taking option of the `capabilities` command (such as `--observations`) was passed as the last argument, or its next token was another `--flag`. `requireValue` refuses missing or flag-like values.

Source

Thrown at src/cli/capabilities.ts:119

      case "--lockfile":
        parsed.lockfile = requireValue(args, index, arg);
        index += 1;
        break;
      case "--observations":
        parsed.observations = requireValue(args, index, arg);
        index += 1;
        break;
      default:
        if (arg.startsWith("--")) throw new Error(`Unknown capabilities option: ${arg}`);
        break;
    }
  }
  return parsed;
}

function requireValue(args: string[], index: number, flag: string): string {
  const value = args[index + 1];
  if (!value || value.startsWith("--")) throw new Error(`${flag} requires a value`);
  return value;
}

function printResult(result: unknown, json: boolean): void {
  if (json) {
    console.log(JSON.stringify(result, null, 2));
    return;
  }
  const check = result as Partial<CapabilityCheckResult> & { lockfile?: string };
  console.log(`${check.ok ? "OK" : "FAIL"}: capabilities ${check.ok ? "satisfied" : "check failed"}`);
  if (check.lockfile) console.log(`lockfile: ${check.lockfile}`);
  for (const warning of check.warnings ?? []) console.warn(`warning ${warning.code}: ${warning.message}`);
  for (const failure of check.failures ?? []) console.error(`${failure.code}: ${failure.message}`);
}

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply a concrete value right after the flag: `--observations <value>`
  2. If the next token is a flag, reorder so the value comes immediately after its option

Example fix

# before
omx capabilities get --observations --json

# after
omx capabilities get --json --observations my-obs
Defensive patterns

Strategy: validation

Validate before calling

function hasValueAfter(args: string[], flag: string): boolean {
  const i = args.indexOf(flag);
  if (i === -1) return true;
  const next = args[i + 1];
  return !!next && !next.startsWith('--');
}
if (!hasValueAfter(args, '--observations')) {
  console.error('--observations needs a value'); process.exit(1);
}

Try / catch

try {
  await capabilitiesCommand(args);
} catch (e) {
  if (/requires a value/.test((e as Error).message)) { /* prompt user for the missing value */ }
  else throw e;
}

Prevention

When it happens

Trigger: `omx capabilities get --observations` with nothing after it, or `omx capabilities get --observations --json` where the value slot is occupied by another flag.

Common situations: Forgetting the argument value in shell scripts, option ordering mistakes, or quoting bugs that swallow the value.

Related errors


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