{"record":{"id":"478d68554e48877f","repo":"santifer/career-ops","slug":"arg-requires-a-path","errorCode":null,"errorMessage":"${arg} requires a path","messagePattern":"(.+?) requires a path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"verify-cv-facts.mjs","lineNumber":890,"sourceCode":"    const details = [];\n    if (result.invented.length) details.push(`metric-like claims absent from sources: ${result.invented.join(', ')}`);\n    if (result.unsupportedFacts.length) details.push(`non-metric facts absent from sources: ${result.unsupportedFacts.map(({ kind, value }) => `${kind}=${value}`).join(', ')}`);\n    if (result.forbidden.length) details.push(`forbidden phrases found: ${result.forbidden.join(', ')}`);\n    throw new Error(`Fact check failed${options.label ? ` for ${options.label}` : ''}: ${details.join('; ')}`);\n  }\n  return result;\n}\n\n/** Parse the fact-validator command-line arguments. */\nfunction parseCliArgs(args) {\n  const sourcePaths = [];\n  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. */","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/santifer/career-ops/blob/e7abd431fce9348a95261acac9e0c14779c35df8/verify-cv-facts.mjs#L872-L908","documentation":"parseCliArgs() in verify-cv-facts.mjs requires that the --source and --config flags be followed by a value. When argv ends with the flag (or the next token is an empty string), it throws '${arg} requires a path'.","triggerScenarios":"Running e.g. `node verify-cv-facts.mjs cv.md --source` or `--config` as the last argument, or with an empty string after it due to shell variable expansion ($SRC unset).","commonSituations":"Shell variable for the source path is unset/empty so the flag dangles; copy-pasted command truncated before the path; misremembering flag syntax (putting the path before the flag).","solutions":["Supply the path directly after the flag: --source cv.md --sources config ... i.e. `--source <file>` and `--config <file>`","Check that any shell variable used for the path is set: echo $SOURCE_PATH","Reorder so the value follows the flag: node verify-cv-facts.mjs cv.md --source cv.md"],"exampleFix":"// before\n$ node verify-cv-facts.mjs cv.md --source\n// after\n$ node verify-cv-facts.mjs cv.md --source sources/cv.md","handlingStrategy":"validation","validationCode":"const i = args.indexOf('--source');\nif (i !== -1 && (!args[i + 1] || args[i + 1].startsWith('--'))) {\n  console.error('--source requires a path');\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const parsed = parseCliArgs(process.argv.slice(2));\n} catch (err) {\n  if (err.message.includes('requires a path')) {\n    console.error(`${err.message}\\nUsage: verify-cv-facts.mjs <target> --source <file> [--config <file>]`);\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Always put the value immediately after the flag","Avoid unset shell variables in commands: use \"${SRC:?}\" to fail fast on empty vars","Wrap CLI invocations in scripts that assert required arguments first"],"tags":["cli","argument-parsing"],"backgroundTag":"missing-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"}