{"record":{"id":"f69998343d365d0f","repo":"Yeachan-Heo/oh-my-codex","slug":"missing-value-for-input","errorCode":null,"errorMessage":"Missing value for --input","messagePattern":"Missing value for --input","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/mcp-parity.ts","lineNumber":107,"sourceCode":"\nexport function parseMcpCliArgs(args: string[]): ParsedMcpCliArgs {\n  if (args.length === 0 || args[0] === \"--help\" || args[0] === \"-h\" || args[0] === \"help\") {\n    return { toolName: null, input: {}, json: false, help: true };\n  }\n\n  const [toolName, ...rest] = args;\n  let input: Record<string, unknown> = {};\n  let json = false;\n\n  for (let i = 0; i < rest.length; i += 1) {\n    const token = rest[i];\n    if (token === \"--json\") {\n      json = true;\n      continue;\n    }\n    if (token === \"--input\") {\n      const next = rest[i + 1];\n      if (!next) throw new Error(\"Missing value for --input\");\n      input = parseInputJson(next);\n      i += 1;\n      continue;\n    }\n    if (token === \"--help\" || token === \"-h\" || token === \"help\") {\n      return { toolName: null, input: {}, json: false, help: true };\n    }\n    throw new Error(`Unknown argument: ${token}`);\n  }\n\n  return { toolName, input, json, help: false };\n}\n\nfunction extractPayload(result: ToolHandlerResult): unknown {\n  const text = result.content\n    ?.filter((entry) => entry.type === \"text\" && typeof entry.text === \"string\")\n    .map((entry) => entry.text as string)\n    .join(\"\\n\")","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/mcp-parity.ts#L89-L125","documentation":"While parsing MCP parity CLI args, --input must be immediately followed by its value token. If the next token is missing (end of argv), the parser throws `Missing value for --input` before attempting JSON parsing.","triggerScenarios":"Invoking the command with --input as the last token, e.g. `... run-tool --input` or `... --input --json` style truncation where no following token exists (note: a following token that starts with -- would be consumed as the value here only if present; absence throws).","commonSituations":"Truncated command lines from copy-paste; scripts building args arrays that drop the value on empty variables (\"$VAR\" unquoted/unset expanding to nothing); CI pipelines with templated arguments that render empty.","solutions":["Supply the JSON value right after --input: --input '{\"k\":1}'","Check shell variable expansion — use \"${VAR:?set}\" or default '{} ' so empty vars don't vanish","Echo the full command before running in scripts to catch truncation"],"exampleFix":"# before (EMPTY_INPUT unset -> value disappears)\nmycli t --input $EMPTY_INPUT\n\n# after\nmycli t --input \"${EMPTY_INPUT:-{}}\"","handlingStrategy":"validation","validationCode":"const i = args.indexOf('--input');\nif (i !== -1 && (i === args.length - 1 || args[i + 1].startsWith('--'))) {\n  console.error('--input requires a JSON object value');\n  process.exit(2);\n}","typeGuard":"function hasInputValue(args: readonly string[]): boolean {\n  const i = args.indexOf('--input');\n  return i === -1 || (i + 1 < args.length && !args[i + 1].startsWith('--'));\n}","tryCatchPattern":"try { await parseMcpCliArgs(args); }\ncatch (e) { if (/Missing value for --input/.test(String(e))) { printUsage(); process.exit(2); } throw e; }","preventionTips":["Use \"${VAR:?required}\" for script-supplied values","Always pair --input with an explicit JSON literal"],"tags":["cli","missing-argument","argument-parsing"],"backgroundTag":"missing-cli-option-value","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}