{"record":{"id":"f77205560cfd32fe","repo":"Egonex-AI/Understand-Anything","slug":"unexpected-positional-argument-arg","errorCode":null,"errorMessage":"Unexpected positional argument: ${arg}","messagePattern":"Unexpected positional argument: (.+?)","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":241,"sourceCode":"    if (arg.startsWith('--label=')) {\n      label = arg.slice('--label='.length);\n      continue;\n    }\n    if (arg === '--concurrency') {\n      const raw = takeValue(argv, i, '--concurrency');\n      concurrency = parseConcurrency(raw);\n      i += 1;\n      continue;\n    }\n    if (arg.startsWith('--concurrency=')) {\n      concurrency = parseConcurrency(arg.slice('--concurrency='.length));\n      continue;\n    }\n    if (arg.startsWith('-')) {\n      throw new CliUsageError(`Unknown option: ${arg}`);\n    }\n    if (repoValue) {\n      throw new CliUsageError(`Unexpected positional argument: ${arg}`);\n    }\n    repoValue = arg;\n  }\n\n  if (help) return { help: true };\n  if (!repoValue) throw new CliUsageError('A repository path is required');\n  if (outputValue === null || outputValue.trim() === '') {\n    throw new CliUsageError('--output is required and must be non-empty');\n  }\n  if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 32) {\n    throw new CliUsageError('--concurrency must be an integer between 1 and 32');\n  }\n\n  const repoRoot = resolve(cwd, repoValue);\n  if (!existsSync(repoRoot)) {\n    throw new CliUsageError(`Repository path does not exist: ${repoValue}`);\n  }\n  if (!statSync(repoRoot).isDirectory()) {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L223-L259","documentation":"CliUsageError thrown by parseArgs when a positional (non-flag) argument appears but repoValue is already set. The command accepts exactly one positional — the repository path — and a second one is rejected as unexpected.","triggerScenarios":"Passing two repository paths; a positional argument after the repo when an option was meant to be a flag (e.g. forgetting '--' or a flag prefix); trailing tokens that are not options.","commonSituations":"Specifying both a source and output as positionals instead of using --output; a stray token from a shell glob; misreading the usage and supplying extra positional arguments.","solutions":["Provide only one positional (the repository path); use --output for the report path.","Quote or escape shell globs that expand to multiple tokens.","Re-run with --help to confirm the single-positional contract.","If you meant the extra token as an option value, prefix it with the correct flag."],"exampleFix":"# before\nnode benchmark-large-repo.mjs myrepo reports/out.json\n# after\nnode benchmark-large-repo.mjs myrepo --output reports/out.json","handlingStrategy":"validation","validationCode":"const positionals = argv.filter(a => !a.startsWith('-'));\nif (positionals.length > 1) { /* reject early */ }","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":["Pass exactly one positional (the repo) and use flags for everything else.","Quote shell globs that could expand to multiple positionals."],"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"}