santifer/career-ops · error
unexpected extra positional argument
Error message
unexpected extra positional argument: ${arg} What it means
CLI argument validation in verify-cv-facts.mjs's parseCliArgs: a positional (non -- prefixed) argument appeared after the target argument was already set — the command accepts at most one positional target (the file to validate). The interpolated value is the surplus argument; the input at fault is the second bare token on the command line.
Solutions
- Run the validator once per target file, quoting each path
- Quote paths containing spaces: "my cv.md"
- Remove the extra token — check that extra files aren't meant to be --source arguments instead
Example fix
// before $ node verify-cv-facts.mjs cv.md cover.md // after $ node verify-cv-facts.mjs cv.md --source cv.md $ node verify-cv-facts.mjs cover.md --source cv.md
Defensive patterns
Strategy: validation
Validate before calling
const positionals = args.filter(a => !a.startsWith('--'));
if (positionals.length > 1) { console.error('expected exactly one target file'); process.exit(2); } Try / catch
try {
const parsed = parseCliArgs(process.argv.slice(2));
} catch (err) {
if (err.message.startsWith('unexpected extra positional argument')) {
console.error(`${err.message} — pass one target per run; extra files go via --source`);
process.exit(2);
}
throw err;
} Prevention
- Quote every path, especially ones with spaces
- One target file per invocation; loop in a shell script for batches
- Double-check copy-pasted commands for leftover tokens
When it happens
Trigger: Passing two files, e.g. `node verify-cv-facts.mjs cv.md cover-letter.md`, or an unquoted path with spaces that splits into two argv tokens.
Common situations: Assuming multiple targets can be validated in one run; unquoted filenames containing spaces; leaving stray tokens from a copy-pasted command.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- requires a path
- --limit must be an integer from 1 to 100
- --months must be an integer from 1 to 120
- unknown option
- unknown option
AI-assisted analysis of santifer/career-ops@e7abd431fc (2026-09-16).
Data as JSON: /api/errors/83e4478c2c41e651.
Report an issue: GitHub.
Appendix: source
Thrown at verify-cv-facts.mjs:902
let targetArg = '';
let configPath = DEFAULT_CONFIG;
let json = false;
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === '--source' || arg === '--config') {
if (!args[i + 1]) throw new Error(`${arg} requires a path`);
if (arg === '--source') sourcePaths.push(args[++i]);
else configPath = args[++i];
} else if (arg === '--help' || arg === '-h') {
return { help: true };
} else if (arg === '--json') {
json = true;
} else if (arg.startsWith('--')) {
throw new Error(`unknown option: ${arg}`);
} else if (!targetArg) {
targetArg = arg;
} else {
throw new Error(`unexpected extra positional argument: ${arg}`);
}
}
return { targetArg, sourcePaths, configPath, json, help: false };
}
/** Return the command-line usage text. */
function usage() {
return `Usage: node verify-cv-facts.mjs <generated-document> [--source path] [--config path] [--json]
node verify-cv-facts.mjs --self-test
Checks generated candidate-facing text for unsupported metrics and explicitly asserted
non-metric facts (employers, titles, tools, and delegated-work authorship) absent
from source files.
Default sources: cv.md, article-digest.md
Default config: config/cv-facts.json (optional)`;
}
/** Exercise the metric extraction regressions that the shared gate depends on. */View on GitHub (pinned to e7abd431fc)