{"record":{"id":"38e352b72dfe6713","repo":"Egonex-AI/Understand-Anything","slug":"flag-requires-a-value","errorCode":null,"errorMessage":"${flag} requires a value","messagePattern":"(.+?) requires a value","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":131,"sourceCode":"  constructor() {\n    super('Unable to remove temporary benchmark artifacts');\n    this.name = 'BenchmarkArtifactCleanupError';\n  }\n}\n\nexport function cleanupBenchmarkArtifacts(artifactRoot, operations = {}) {\n  const remove = operations.rmSync ?? rmSync;\n  try {\n    remove(artifactRoot, { recursive: true, force: true });\n  } catch {\n    throw new BenchmarkArtifactCleanupError();\n  }\n}\n\nfunction takeValue(argv, index, flag) {\n  const value = argv[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new CliUsageError(`${flag} requires a value`);\n  }\n  return value;\n}\n\nfunction parseConcurrency(value) {\n  return /^[0-9]+$/.test(value) ? Number(value) : Number.NaN;\n}\n\nfunction canonicalizePhysicalPath(pathValue) {\n  const lexicalPath = resolve(withoutExtendedWindowsPrefix(pathValue));\n  const missingComponents = [];\n  let existingAncestor = lexicalPath;\n  let ancestorExists = existsSync(existingAncestor);\n\n  while (!ancestorExists) {\n    const parent = dirname(existingAncestor);\n    if (parent === existingAncestor) break;\n    missingComponents.unshift(basename(existingAncestor));","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L113-L149","documentation":"CliUsageError thrown by the takeValue helper when a flag that expects a following argument (--repo, --output/-o, --label, --concurrency) is followed by a missing value or a value that itself starts with '--'. It prevents silently consuming the next flag as a value.","triggerScenarios":"Passing '--output' as the last token; '--output --label x' (next token is a flag); '--concurrency' at end of argv; any flag whose value token begins with '--'.","commonSituations":"Typing the command without a value; copy-pasting a command where a value was dropped; a shell that swallowed an empty argument; misordering flags so one flag runs into the next.","solutions":["Provide the value immediately after the flag: --output path/to/report.json.","Use the '=' form which does not consume the next token: --output=path/to/report.json.","Ensure the value does not itself start with '--'; if it legitimately does, use the '=' form or quote it differently.","Run the command with --help to confirm the expected flag/value shape."],"exampleFix":"# before\nnode benchmark-large-repo.mjs myrepo --output\n# after\nnode benchmark-large-repo.mjs myrepo --output=reports/out.json","handlingStrategy":"validation","validationCode":"function flagHasValue(argv: string[], index: number): boolean {\n  const next = argv[index + 1];\n  return Boolean(next) && !next.startsWith('--');\n}","typeGuard":null,"tryCatchPattern":"try { const opts = parseArgs(argv); } catch (e) { if ((e as Error).name === 'CliUsageError') { console.error(e.message); process.exit(2); } throw e; }","preventionTips":["Always pair a value-expecting flag with its value, or use the '=' form.","Print helpText() on a CliUsageError so the user sees accepted flags."],"tags":["benchmark","cli","argument-parsing"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}