affaan-m/ECC · error · Error
Missing value for ${arg}
Error message
Missing value for ${arg} What it means
In check-plugin-cache.js parseArgs(), after matching a known flag, the parser reads argv[index + 1] as its value. If that value is undefined (flag is last) or starts with '--' (looks like another flag), it throws. This prevents the parser from silently consuming a flag name as a value for the preceding flag.
Source
Thrown at scripts/codex/check-plugin-cache.js:77
'--version': 'version',
};
let parsed = {};
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index];
if (arg === '--help' || arg === '-h') {
parsed = { ...parsed, help: true };
continue;
}
const key = optionKeys[arg];
if (!key) {
throw new Error(`Unknown argument: ${arg}`);
}
const value = argv[index + 1];
if (!value || value.startsWith('--')) {
throw new Error(`Missing value for ${arg}`);
}
index += 1;
parsed = { ...parsed, [key]: value };
}
const options = { ...defaults, ...parsed };
return {
...options,
marketplace: validateCacheSegment('--marketplace', options.marketplace),
plugin: validateCacheSegment('--plugin', options.plugin),
version: validateCacheSegment('--version', options.version),
codexHome: path.resolve(options.codexHome),
pluginDir: options.pluginDir ? path.resolve(options.pluginDir) : null,
};
}
function log(message) {View on GitHub (pinned to 01e15490f0)
Solutions
- Provide a concrete value immediately after each flag, e.g. --codex-home ~/.codex
- If building commands dynamically, verify the value variable is truthy before appending both the flag and its value
- Run with --help to confirm which flags expect values
Example fix
// before node scripts/codex/check-plugin-cache.js --codex-home --plugin ecc // after node scripts/codex/check-plugin-cache.js --codex-home ~/.codex --plugin ecc
Defensive patterns
Strategy: validation
Validate before calling
// Verify each value-expecting flag has a companion value
const FLAGS_REQUIRING_VALUE = new Set(['--codex-home', '--plugin-dir', '--marketplace', '--plugin', '--version']);
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
if (FLAGS_REQUIRING_VALUE.has(argv[i])) {
if (!argv[i + 1] || argv[i + 1].startsWith('--')) {
console.error(`Missing value for ${argv[i]}`);
process.exit(1);
}
}
} Try / catch
try {
const options = parseArgs(process.argv.slice(2));
} catch (error) {
if (error.message.startsWith('Missing value for')) {
console.error(error.message);
console.error('Each flag above requires a value as the next argument.');
usage();
process.exit(2);
}
throw error;
} Prevention
- Place the value immediately after each flag with no gap
- When building commands from variables, check truthiness before appending both flag and value
- Avoid placing two value-expecting flags adjacent without their values
When it happens
Trigger: Passing --codex-home as the last argument with no value; passing --marketplace immediately followed by another flag like --plugin; or a copy-paste error that drops the intended value.
Common situations: Dynamic CLI construction in CI that conditionally appends a flag without its value; scripts that pass flags based on optional environment variables that are unset.
Related errors
- Invalid ${flag}: expected a single cache path segment
- Unknown argument: ${arg}
- --write requires a path
- Unknown argument: ${arg}
- ${label} must be a positive integer
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/5c639640a7074b8d.
Report an issue: GitHub.