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

Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_FLAG}

Error message

Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_FLAG}

What it means

resolveRuntimeCliInlineInput scans argv for the runtime JSON input flag; if the flag is present but the next argv element is missing (flag is last) or blank, there is no payload to parse, so it throws rather than silently reading stdin or misparsing. This protects against a truncated command line.

Source

Thrown at src/team/runtime-cli.ts:267

  if (!input.tasks || !Array.isArray(input.tasks) || input.tasks.length === 0) missing.push('tasks');
  if (!input.cwd) missing.push('cwd');
  return missing;
}

export function resolveRuntimeCliTask(input: Pick<CliInput, 'task' | 'tasks'>): string {
  const explicitTask = typeof input.task === 'string' ? input.task.trim() : '';
  if (explicitTask !== '') {
    return explicitTask;
  }
  return input.tasks.map((task) => task.subject).join('; ');
}

export function resolveRuntimeCliInlineInput(argv: readonly string[]): string | null {
  const index = argv.indexOf(RUNTIME_CLI_INPUT_JSON_FLAG);
  if (index !== -1) {
    const payload = argv[index + 1];
    if (typeof payload !== 'string' || payload.trim() === '') {
      throw new Error(`Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_FLAG}`);
    }
    return payload;
  }

  const base64Index = argv.indexOf(RUNTIME_CLI_INPUT_JSON_BASE64_FLAG);
  if (base64Index === -1) {
    return null;
  }
  const payload = argv[base64Index + 1];
  if (typeof payload !== 'string' || payload.trim() === '') {
    throw new Error(`Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_BASE64_FLAG}`);
  }
  return Buffer.from(payload.trim(), 'base64url').toString('utf-8');
}

async function readRuntimeCliRawInput(argv: readonly string[]): Promise<string> {
  const inlineInput = resolveRuntimeCliInlineInput(argv);
  if (inlineInput != null) {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply the JSON payload immediately after the flag, properly quoted
  2. If the payload is large/has quotes, use the base64 variant instead
  3. Fix argv-building code so flag and value are pushed together

Example fix

// before
spawn('omx', ['team','start','--input-json']);
// after
spawn('omx', ['team','start','--input-json', JSON.stringify(payload)]);
Defensive patterns

Strategy: validation

Validate before calling

const i = argv.indexOf('--input-json'); // use the real flag constant
if (i !== -1 && (i + 1 >= argv.length || !argv[i+1].trim())) {
  throw new Error('provide JSON payload immediately after the flag');
}

Try / catch

try { resolveRuntimeCliInlineInput(argv); } catch (e) { if (e instanceof Error && e.message.includes('Missing JSON payload')) { /* fix argv construction */ } throw e; }

Prevention

When it happens

Trigger: Invoking the CLI with `--input-json` as the final argument, or followed by another flag (`--input-json --verbose`), or an empty-string argument.

Common situations: Shell quoting bugs that drop the payload, argv construction code that pushes the flag conditionally but not the value, or user-truncated commands.

Related errors


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