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

Missing value after --input

Error message

Missing value after --input

What it means

Thrown by parseTeamApiArgs when `--input` is the last token, so there is no following argument to parse as JSON. The CLI requires --input to be immediately followed by its JSON payload.

Source

Thrown at src/cli/team.ts:538

  operation: TeamApiOperation;
  input: Record<string, unknown>;
  json: boolean;
} {
  const operation = resolveTeamApiOperation(args[0] || '');
  if (!operation) {
    throw new Error(`Usage: omx team api <operation> [--input <json>] [--json]\nSupported operations: ${TEAM_API_OPERATIONS.join(', ')}`);
  }
  let input: Record<string, unknown> = {};
  let json = false;
  for (let i = 1; i < args.length; i += 1) {
    const token = args[i];
    if (token === '--json') {
      json = true;
      continue;
    }
    if (token === '--input') {
      const next = args[i + 1];
      if (!next) throw new Error('Missing value after --input');
      try {
        const parsed = JSON.parse(next) as unknown;
        if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
          throw new Error('input must be a JSON object');
        }
        input = parsed as Record<string, unknown>;
      } catch (error) {
        throw new Error(`Invalid --input JSON: ${error instanceof Error ? error.message : String(error)}`);
      }
      i += 1;
      continue;
    }
    if (token.startsWith('--input=')) {
      const raw = token.slice('--input='.length);
      try {
        const parsed = JSON.parse(raw) as unknown;
        if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
          throw new Error('input must be a JSON object');

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply the JSON object right after --input: `omx team api <op> --input '{"team":"acme"}'`.
  2. If generating the command in a script, guard that the input variable is non-empty before appending --input.
  3. Alternatively use the `--input=<json>` form so the value is never a separate token.

Example fix

# before
omx team api create --input
# after
omx team api create --input '{"name":"acme"}'
Defensive patterns

Strategy: validation

Validate before calling

const i = args.indexOf('--input');
if (i !== -1 && (i === args.length - 1 || args[i + 1].startsWith('--'))) {
  throw new Error('Missing value after --input');
}
// or prefer the --input=<json> form so a value can never be omitted

Type guard

function hasInputValue(args: string[]): boolean {
  const i = args.indexOf('--input');
  return i === -1 || i + 1 < args.length;
}

Try / catch

try { await teamApi(args); } catch (e) {
  if (e instanceof Error && e.message === 'Missing value after --input') { /* prompt for input or default to {} */ }
  else throw e;
}

Prevention

When it happens

Trigger: `omx team api <op> --input` with nothing after it, or a shell quoting mistake that drops the JSON argument.

Common situations: Building the command dynamically and the input variable is empty/unset, trailing-flag typos, or a truncated command line in a script.

Related errors


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