santifer/career-ops · error · Error

${arg} requires a path

Error message

${arg} requires a path

What it means

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.

Source

Thrown at verify-cv-facts.mjs:430

    const details = [];
    if (result.invented.length) details.push(`metric-like claims absent from sources: ${result.invented.join(', ')}`);
    if (result.unsupportedFacts.length) details.push(`non-metric facts absent from sources: ${result.unsupportedFacts.map(({ kind, value }) => `${kind}=${value}`).join(', ')}`);
    if (result.forbidden.length) details.push(`forbidden phrases found: ${result.forbidden.join(', ')}`);
    throw new Error(`Fact check failed${options.label ? ` for ${options.label}` : ''}: ${details.join('; ')}`);
  }
  return result;
}

/** Parse the fact-validator command-line arguments. */
function parseCliArgs(args) {
  const sourcePaths = [];
  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. */

View on GitHub (pinned to 60398d6549)

Solutions

  1. Supply the missing path right after the flag: `--source cv.md` / `--config my-gate.json`
  2. If you meant no value, drop the flag entirely — both --source and --config have defaults
  3. Quote paths containing spaces so a single token follows the flag

Example fix

# before
node verify-cv-facts.mjs output/cv.md --source
# after
node verify-cv-facts.mjs output/cv.md --source cv.md
Defensive patterns

Strategy: validation

Validate before calling

function parseValueFlag(args, name) {
  const i = args.indexOf(name);
  if (i === -1) return undefined;
  const v = args[i + 1];
  if (!v || v.startsWith('--')) throw new Error(`${name} requires a path`);
  return v;
}

Try / catch

try {
  runCli(argv);
} catch (err) {
  if (/requires a path$/.test(err.message)) {
    console.error(`${err.message}\nUsage: node verify-cv-facts.mjs <doc> [--source p] [--config p] [--json]`);
    process.exit(2); // usage error, distinct from verification failure
  }
  throw err;
}

Prevention

When it happens

Trigger: `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]).

Common situations: 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.

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


AI-assisted analysis of santifer/career-ops@60398d6549 (2026-08-20). Data as JSON: /api/errors/478d68554e48877f. Report an issue: GitHub.