Yeachan-Heo/oh-my-codex · error
Missing JSON value after --input
Error message
Missing JSON value after --input
What it means
The --input flag appeared as the last token of the state command's argument list, so there is no JSON value following it. Both the space form and --input= exist; this error covers the space form without a value.
Source
Thrown at src/cli/state.ts:104
if (isHelpArg(args[1])) {
stdout(STATE_HELP);
return;
}
let inputValue: string | undefined;
let inputFileValue: string | undefined;
let modeValue: string | undefined;
let json = false;
for (let index = 1; index < args.length; index += 1) {
const arg = args[index];
if (arg === '--json') {
json = true;
continue;
}
if (arg === '--input') {
const next = args[index + 1];
if (!next) {
throw new Error('Missing JSON value after --input');
}
inputValue = next;
index += 1;
continue;
}
if (arg.startsWith('--input=')) {
inputValue = arg.slice('--input='.length);
continue;
}
if (arg === '--input-file') {
const next = args[index + 1];
if (!next) {
throw new Error('Missing path value after --input-file');
}
inputFileValue = next;
index += 1;
continue;
}View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Follow --input with the JSON: `state set --input '{"a":1}'`
- Guard the variable: `: "${JSON:?JSON required}"` before invoking
- Or use --input-file to avoid inline quoting entirely
Example fix
# before
state set --input # $JSON was empty
# after
JSON='{"a":1}'
state set --input "$JSON" Defensive patterns
Strategy: validation
Validate before calling
if (!json || json.trim().length === 0) {
throw new Error('refusing to run: --input value is empty');
}
spawn('state', ['set', '--input', json]); Prevention
- Use `: ${JSON:?}` guards so empty vars fail early
- Pass args programmatically (execFile) instead of shell interpolation
When it happens
Trigger: `state set --input` with nothing after it, often from an empty shell variable expansion ending the command.
Common situations: `state set --input "$JSON"` where JSON is empty/unset and the shell drops the token; truncated command lines in scripts.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- Missing path value after --input-file
- --keep-policy must be one of: score_improvement, pass_only
- Unknown capabilities subcommand: ${parsed.subcommand}
- Unknown capabilities option: ${arg}
- ${flag} requires a value
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/2e5df3571930dbff.
Report an issue: GitHub.