santifer/career-ops · error · Error
Missing value for
Error message
Missing value for ${arg} What it means
parseArgs in application-answers.mjs treats any unrecognized --flag as a flag-with-value pair, consuming the next argv element as its value. If the next element is missing or itself starts with '--' (i.e. it is another flag), there is no value to consume, so it throws "Missing value for <flag>". This also fires for genuine typos of known value-taking flags.
Solutions
- Supply the value immediately after the flag: `node application-answers.mjs --state submitted`.
- Check shell variables feeding the command are non-empty (quote and default them: "${STATE:?STATE not set}").
- Fix flag-name typos — an unknown flag followed by another flag triggers this error even if you intended it as a boolean.
Example fix
// before node application-answers.mjs --write --state # value missing // after STATE=submitted node application-answers.mjs --write --state "$STATE"
Defensive patterns
Strategy: validation
Validate before calling
const VALUE_FLAGS = new Set(['--state', '--date', '--company', '--question']);
for (const f of VALUE_FLAGS) {
const i = process.argv.indexOf(f);
if (i !== -1 && (!process.argv[i + 1] || process.argv[i + 1].startsWith('--'))) {
throw new Error(`${f} requires a value`);
}
} Try / catch
try {
const args = parseArgs(process.argv.slice(2));
} catch (err) {
if (err.message.startsWith('Missing value for')) {
console.error(`${err.message}. Usage: application-answers.mjs --<flag> <value>`);
process.exit(2);
}
throw err;
} Prevention
- In shell scripts, require value variables with "${STATE:?STATE is unset}" before invoking the CLI.
- Quote values that may start with '-' or look like flags (pass as --flag="value" and verify).
- Double-check flag spelling: unrecognized flags are silently treated as value-taking options.
When it happens
Trigger: Running the CLI with a value-taking flag at the end of the command line with nothing after it (e.g. `--state`), or with the next token being another flag (e.g. `--state --strict`), or passing a misspelled flag like `--stat filled` that the parser then treats as an unknown value-taking option.
Common situations: Shell scripts where a variable holding the value is empty (`--state "$STATE"` with STATE unset); copying an example and dropping the value; typos in flag names so the parser doesn't recognize them as boolean flags.
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
- Application Answers section has
- -- must be a percentage (e.g. 70 or 70%), got
- USAGE
- requires a path
- changedSections must be an array
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/a51bb0410ce571cb.
Report an issue: GitHub.
Appendix: source
Thrown at application-answers.mjs:407
const end = nextHeading ? afterHeading + nextHeading.index : report.length;
const before = report.slice(0, start).trimEnd();
const after = report.slice(end).trimStart();
return [before, section, after].filter(Boolean).join('\n\n') + '\n';
}
function parseArgs(argv) {
const args = {};
for (let i = 0; i < argv.length; i += 1) {
const arg = argv[i];
if (arg === '--help' || arg === '-h') args.help = true;
else if (arg === '--read') args.read = true;
else if (arg === '--read-draft') args.readDraft = true;
else if (arg === '--strict') args.strict = true;
else if (arg.startsWith('--')) {
const value = argv[i + 1];
if (!value || value.startsWith('--')) {
throw new Error(`Missing value for ${arg}`);
}
args[arg.slice(2)] = value;
i += 1;
}
}
return args;
}
function usage() {
return [
'Usage: node application-answers.mjs --report <report.md> --input <answers.json> [--state filled|submitted] [--date YYYY-MM-DD]',
' node application-answers.mjs --report <report.md> --read [--strict]',
' node application-answers.mjs --report <report.md> --read-draft',
'',
'The input JSON may contain: freeText, selections, fieldValues, files, date, state.',
'--read prints the parsed ## Application Answers snapshot as JSON (null when the section is absent).',
'--strict makes --read refuse a partially unreadable section, naming every line it could not parse,',
'instead of skipping it. Recovery callers (modes/apply.md) want the refusal; the default stays total.',View on GitHub (pinned to aac998c7ed)