{"record":{"id":"1fb5bb1c19fd9ff9","repo":"Egonex-AI/Understand-Anything","slug":"markdown-report-path-must-be-outside-the-subject-r","errorCode":null,"errorMessage":"Markdown report path must be outside the subject repository","messagePattern":"Markdown report path must be outside the subject repository","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":274,"sourceCode":"  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:\n  node scripts/benchmark-large-repo.mjs <repo-path> --output <path> [options]\n  node scripts/benchmark-large-repo.mjs --repo <repo-path> --output <path> [options]\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L256-L292","documentation":"CliUsageError thrown by parseArgs when the derived Markdown report path is inside (or equal to) the subject repository. The markdown path is computed from the JSON output path by swapping/adding a .md extension, so an output path inside the repo also drags the markdown path inside it; this guard catches the markdown path specifically (e.g. when the JSON path is just outside but the computed .md lands inside, or as a paired safety check).","triggerScenarios":"An --output path whose computed .md variant resolves inside repoRoot; typically paired with error 17 but can fire independently when the .json/.md extension swap changes directory membership in an edge case.","commonSituations":"Output path placed at the repo boundary such that the markdown sibling lands inside; naming the output with a non-.json extension so the .md is appended and lands inside the repo.","solutions":["Move the output path fully outside the repository so both the JSON and its Markdown sibling are external.","Use an absolute path in a separate reports directory.","Confirm both the JSON and Markdown targets are outside repoRoot before running.","Run with --help to recall the external-artifacts requirement."],"exampleFix":"# before\nnode benchmark-large-repo.mjs myrepo --output myrepo-report.json\n# after\nnode benchmark-large-repo.mjs myrepo --output ../reports/out.json","handlingStrategy":"validation","validationCode":"import { isPathInsideOrEqual } from './lib/large-repo-benchmark.mjs';\nconst md = outputPath.toLowerCase().endsWith('.json')\n  ? outputPath.slice(0, -'.json'.length) + '.md'\n  : outputPath + '.md';\nif (isPathInsideOrEqual(repoRoot, resolve(cwd, md))) { /* move output outside 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":["Place both JSON and Markdown reports in an external reports directory.","Pick output paths whose .md sibling also resolves outside the repo."],"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"}