{"record":{"id":"e4bfda975be739ac","repo":"Egonex-AI/Understand-Anything","slug":"output-must-be-outside-the-subject-repository","errorCode":null,"errorMessage":"--output must be outside the subject repository","messagePattern":"--output must be outside the subject repository","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":271,"sourceCode":"  }\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()) {\n    throw new CliUsageError(`Repository path is not a directory: ${repoValue}`);\n  }\n\n  const outputPath = resolve(cwd, outputValue);\n  const markdownPath = resolve(\n    cwd,\n    outputPath.toLowerCase().endsWith('.json')\n      ? `${outputPath.slice(0, -'.json'.length)}.md`\n      : `${outputPath}.md`,\n  );\n  if (isPathInsideOrEqual(repoRoot, outputPath)) {\n    throw new CliUsageError('--output must be outside the subject repository');\n  }\n  if (isPathInsideOrEqual(repoRoot, markdownPath)) {\n    throw new CliUsageError('Markdown report path must be outside the subject repository');\n  }\n\n  return {\n    help: false,\n    repoRoot,\n    outputPath,\n    markdownPath,\n    label: label || basename(repoRoot),\n    concurrency,\n    keepArtifacts,\n  };\n}\n\nexport function helpText() {\n  return `Usage:","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L253-L289","documentation":"CliUsageError thrown by parseArgs when the resolved output JSON path is inside (or equal to) the subject repository root. The benchmark intentionally writes all artifacts outside the repo to keep the subject tree clean and to avoid contaminating git metadata/digests used for reproducibility.","triggerScenarios":"Passing --output path/to/report.json where the resolved path falls under repoRoot; pointing output at the repo root itself; using a relative path that resolves into the repo when combined with cwd.","commonSituations":"Defaulting the output to inside the project for convenience; a relative path that happened to land inside the repo; misunderstanding the requirement that artifacts stay external.","solutions":["Choose an output directory outside the subject repository, e.g. ../reports/out.json.","Use an absolute path in a separate reports directory.","Confirm with --help that artifacts must live outside the subject repo.","If you need the report in the repo later, copy it there after the run completes."],"exampleFix":"# before\nnode benchmark-large-repo.mjs myrepo --output myrepo/out.json\n# after\nnode benchmark-large-repo.mjs myrepo --output ../reports/out.json","handlingStrategy":"validation","validationCode":"import { isPathInsideOrEqual } from './lib/large-repo-benchmark.mjs';\nif (isPathInsideOrEqual(repoRoot, resolve(cwd, outputValue))) { /* choose a path outside the repo */ }","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 write reports to a directory outside the subject repository.","Use absolute paths for output to avoid cwd-related surprises."],"tags":["benchmark","cli","filesystem","path","integrity"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}