{"record":{"id":"8d7c78f9b6596371","repo":"Yeachan-Heo/oh-my-codex","slug":"missing-json-payload-for-runtime-cli-input-json","errorCode":null,"errorMessage":"Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_FLAG}","messagePattern":"Missing JSON payload for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime-cli.ts","lineNumber":267,"sourceCode":"  if (!input.tasks || !Array.isArray(input.tasks) || input.tasks.length === 0) missing.push('tasks');\n  if (!input.cwd) missing.push('cwd');\n  return missing;\n}\n\nexport function resolveRuntimeCliTask(input: Pick<CliInput, 'task' | 'tasks'>): string {\n  const explicitTask = typeof input.task === 'string' ? input.task.trim() : '';\n  if (explicitTask !== '') {\n    return explicitTask;\n  }\n  return input.tasks.map((task) => task.subject).join('; ');\n}\n\nexport function resolveRuntimeCliInlineInput(argv: readonly string[]): string | null {\n  const index = argv.indexOf(RUNTIME_CLI_INPUT_JSON_FLAG);\n  if (index !== -1) {\n    const payload = argv[index + 1];\n    if (typeof payload !== 'string' || payload.trim() === '') {\n      throw new Error(`Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_FLAG}`);\n    }\n    return payload;\n  }\n\n  const base64Index = argv.indexOf(RUNTIME_CLI_INPUT_JSON_BASE64_FLAG);\n  if (base64Index === -1) {\n    return null;\n  }\n  const payload = argv[base64Index + 1];\n  if (typeof payload !== 'string' || payload.trim() === '') {\n    throw new Error(`Missing JSON payload for ${RUNTIME_CLI_INPUT_JSON_BASE64_FLAG}`);\n  }\n  return Buffer.from(payload.trim(), 'base64url').toString('utf-8');\n}\n\nasync function readRuntimeCliRawInput(argv: readonly string[]): Promise<string> {\n  const inlineInput = resolveRuntimeCliInlineInput(argv);\n  if (inlineInput != null) {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime-cli.ts#L249-L285","documentation":"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.","triggerScenarios":"Invoking the CLI with `--input-json` as the final argument, or followed by another flag (`--input-json --verbose`), or an empty-string argument.","commonSituations":"Shell quoting bugs that drop the payload, argv construction code that pushes the flag conditionally but not the value, or user-truncated commands.","solutions":["Supply the JSON payload immediately after the flag, properly quoted","If the payload is large/has quotes, use the base64 variant instead","Fix argv-building code so flag and value are pushed together"],"exampleFix":"// before\nspawn('omx', ['team','start','--input-json']);\n// after\nspawn('omx', ['team','start','--input-json', JSON.stringify(payload)]);","handlingStrategy":"validation","validationCode":"const i = argv.indexOf('--input-json'); // use the real flag constant\nif (i !== -1 && (i + 1 >= argv.length || !argv[i+1].trim())) {\n  throw new Error('provide JSON payload immediately after the flag');\n}","typeGuard":null,"tryCatchPattern":"try { resolveRuntimeCliInlineInput(argv); } catch (e) { if (e instanceof Error && e.message.includes('Missing JSON payload')) { /* fix argv construction */ } throw e; }","preventionTips":["Always push flag and value as a pair when building argv","Use base64 flag for payloads containing quotes or newlines","Quote payloads in shell invocations"],"tags":["cli-validation","argv-parsing","json-input"],"backgroundTag":"missing-cli-argument-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}