{"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":"Error","httpStatus":null,"severity":"error","filePath":"verify-cv-facts.mjs","lineNumber":430,"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":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/santifer/career-ops/blob/60398d6549a46f5266929538af21cfab94badc75/verify-cv-facts.mjs#L412-L448","documentation":"verify-cv-facts.mjs's parseCliArgs() requires a value after --source and --config: if the flag is the last argument (or followed by another flag), args[i+1] is undefined and this error names the flag that lacked a path. It prevents an empty string from silently being used as a file path.","triggerScenarios":"`node verify-cv-facts.mjs cv.pdf --source` (flag at end), or `--config` followed immediately by another flag like `--config --json`. The next token must exist and be consumed as the path (args[++i]).","commonSituations":"Shell line-wrapping or copy-paste truncating the command; script templates where the path variable expanded empty; tab-completion inserting the flag without the value.","solutions":["Supply the missing path right after the flag: `--source cv.md` / `--config my-gate.json`","If you meant no value, drop the flag entirely — both --source and --config have defaults","Quote paths containing spaces so a single token follows the flag"],"exampleFix":"# before\nnode verify-cv-facts.mjs output/cv.md --source\n# after\nnode verify-cv-facts.mjs output/cv.md --source cv.md","handlingStrategy":"validation","validationCode":"function parseValueFlag(args, name) {\n  const i = args.indexOf(name);\n  if (i === -1) return undefined;\n  const v = args[i + 1];\n  if (!v || v.startsWith('--')) throw new Error(`${name} requires a path`);\n  return v;\n}","typeGuard":null,"tryCatchPattern":"try {\n  runCli(argv);\n} catch (err) {\n  if (/requires a path$/.test(err.message)) {\n    console.error(`${err.message}\\nUsage: node verify-cv-facts.mjs <doc> [--source p] [--config p] [--json]`);\n    process.exit(2); // usage error, distinct from verification failure\n  }\n  throw err;\n}","preventionTips":["Always type the flag and its value together (--source cv.md)","Quote paths with spaces","In scripts, guard against empty variables: [ -n \"$SRC\" ] && set -- --source \"$SRC\" -- \"$@\""],"tags":["cli","argument-parsing","usage-error"],"backgroundTag":"missing-cli-argument","analyzedSha":"60398d6549a46f5266929538af21cfab94badc75","analyzedAt":"2026-08-20T23:00:06.764Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}