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

Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_BASE64_FLA

Error message

Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_BASE64_FLAG}

What it means

Same guard as 865 but for the base64 input flag: the flag was found in argv but the following element is absent or whitespace-only, so there is no base64url payload to decode. Thrown before any Buffer.from decoding attempt.

Source

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

}

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) {
    return inlineInput.trim();
  }

  const chunks: Buffer[] = [];
  for await (const chunk of process.stdin) {
    chunks.push(chunk as Buffer);
  }
  return Buffer.concat(chunks).toString('utf-8').trim();
}

async function main(): Promise<void> {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Emit the base64url-encoded JSON immediately after the flag
  2. Ensure the encoded variable is non-empty before spawning (fail early at the caller)
  3. Quote the payload to survive shell word-splitting

Example fix

// before
const args = ['--input-json-base64'];
// after
const args = ['--input-json-base64', Buffer.from(JSON.stringify(payload),'utf-8').toString('base64url')];
Defensive patterns

Strategy: validation

Validate before calling

const encoded = Buffer.from(JSON.stringify(payload), 'utf-8').toString('base64url');
if (!encoded) throw new Error('empty payload');
const argv = ['--input-json-base64', encoded];

Try / catch

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

Prevention

When it happens

Trigger: Passing the base64 flag with no value, followed by another flag, or with an empty string; shell pipelines that emit empty base64 output.

Common situations: Automation scripts computing base64 of an empty variable; quoting mistakes; the flag value being consumed by an earlier argv parser.

Related errors


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