{"record":{"id":"83e4478c2c41e651","repo":"santifer/career-ops","slug":"unexpected-extra-positional-argument-arg","errorCode":null,"errorMessage":"unexpected extra positional argument: ${arg}","messagePattern":"unexpected extra positional argument: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"verify-cv-facts.mjs","lineNumber":902,"sourceCode":"  let targetArg = '';\n  let configPath = DEFAULT_CONFIG;\n  let json = false;\n  for (let i = 0; i < args.length; i++) {\n    const arg = args[i];\n    if (arg === '--source' || arg === '--config') {\n      if (!args[i + 1]) throw new Error(`${arg} requires a path`);\n      if (arg === '--source') sourcePaths.push(args[++i]);\n      else configPath = args[++i];\n    } else if (arg === '--help' || arg === '-h') {\n      return { help: true };\n    } else if (arg === '--json') {\n      json = true;\n    } else if (arg.startsWith('--')) {\n      throw new Error(`unknown option: ${arg}`);\n    } else if (!targetArg) {\n      targetArg = arg;\n    } else {\n      throw new Error(`unexpected extra positional argument: ${arg}`);\n    }\n  }\n  return { targetArg, sourcePaths, configPath, json, help: false };\n}\n\n/** Return the command-line usage text. */\nfunction usage() {\n  return `Usage: node verify-cv-facts.mjs <generated-document> [--source path] [--config path] [--json]\n       node verify-cv-facts.mjs --self-test\n\nChecks generated candidate-facing text for unsupported metrics and explicitly asserted\nnon-metric facts (employers, titles, tools, and delegated-work authorship) absent\nfrom source files.\nDefault sources: cv.md, article-digest.md\nDefault config:  config/cv-facts.json (optional)`;\n}\n\n/** Exercise the metric extraction regressions that the shared gate depends on. */","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/santifer/career-ops/blob/e7abd431fce9348a95261acac9e0c14779c35df8/verify-cv-facts.mjs#L884-L920","documentation":"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.","triggerScenarios":"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.","commonSituations":"Assuming multiple targets can be validated in one run; unquoted filenames containing spaces; leaving stray tokens from a copy-pasted command.","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"],"exampleFix":"// before\n$ node verify-cv-facts.mjs cv.md cover.md\n// after\n$ node verify-cv-facts.mjs cv.md --source cv.md\n$ node verify-cv-facts.mjs cover.md --source cv.md","handlingStrategy":"validation","validationCode":"const positionals = args.filter(a => !a.startsWith('--'));\nif (positionals.length > 1) { console.error('expected exactly one target file'); process.exit(2); }","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseCliArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.startsWith('unexpected extra positional argument')) {\n    console.error(`${err.message} — pass one target per run; extra files go via --source`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["cli","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"e7abd431fce9348a95261acac9e0c14779c35df8","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}