{"record":{"id":"70ca67850865092a","repo":"JuliusBrussee/caveman","slug":"at-least-one-report-path-and-the-canonical-span-fixture-path","errorCode":null,"errorMessage":"at least one report path and the canonical span fixture path are required","messagePattern":"at least one report path and the canonical span fixture path are required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":11,"sourceCode":"import { readFile } from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\nimport path from \"node:path\";\nimport Ajv2020 from \"ajv/dist/2020.js\";\n\n// Usage: validate-continuous-improvement.mjs <reportPath...> <spansPath>\n// One or more report fixtures followed by the canonical span fixture they were\n// built from. Every report is validated; an empty span fixture always fails.\nconst packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"..\");\nconst args = process.argv.slice(2);\nif (args.length < 2) throw new Error(\"at least one report path and the canonical span fixture path are required\");\nconst spansPath = args[args.length - 1];\nconst reportPaths = args.slice(0, -1);\n\nconst [reportSchema, spanSchema, spans] = await Promise.all([\n  readFile(path.join(packageRoot, \"schemas\", \"continuous-improvement-report.schema.json\"), \"utf8\").then(JSON.parse),\n  readFile(path.join(packageRoot, \"schemas\", \"canonical-span.schema.json\"), \"utf8\").then(JSON.parse),\n  readFile(spansPath, \"utf8\").then(JSON.parse),\n]);\nconst reports = await Promise.all(reportPaths.map((reportPath) => readFile(reportPath, \"utf8\").then(JSON.parse)));\n\nconst ajv = new Ajv2020({ allErrors: true, strict: true });\nconst validateReport = ajv.compile(reportSchema);\nconst validateSpan = ajv.compile(spanSchema);\nconst contiguouslyContains = (haystack, needle) => {\n  for (let start = 0; start + needle.length <= haystack.length; start += 1) {\n    if (needle.every((operation, offset) => haystack[start + offset] === operation)) return true;\n  }\n  return false;","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L1-L29","documentation":"The validate-continuous-improvement script is a CLI: it takes one or more report fixture paths followed by exactly one canonical span fixture path. If fewer than two argv entries are supplied, it cannot identify both a report and the spans file, so it throws at startup before reading anything. This is the script's argument-count guard, matching its documented usage line.","triggerScenarios":"Running `node scripts/validate-continuous-improvement.mjs` with zero or one arguments — e.g. `... report.json` only (missing spans path), or no arguments at all.","commonSituations":"Forgot the spans fixture argument; npm script wrapper drops arguments (need `--` to forward args through npm run); copy-pasting an example command that used placeholders; shell glob matching no files so the glob is passed literally as one arg or consumed differently.","solutions":["Re-run with at least two arguments: one or more report fixtures, then the canonical span fixture last: `validate-continuous-improvement.mjs report.json spans.json`.","If invoking through `npm run`, pass args after `--` so they reach the script.","Check that your shell globs actually expanded (unmatched globs pass a literal pattern)."],"exampleFix":"// before\nnode scripts/validate-continuous-improvement.mjs report.json\n// after\nnode scripts/validate-continuous-improvement.mjs report.json ../fixtures/spans.json","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args.length < 2) {\n  console.error(\"Usage: validate-continuous-improvement.mjs <reportPath...> <spansPath>\");\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run();\n} catch (e) {\n  if (String(e.message).includes(\"are required\")) {\n    console.error(\"Usage: validate-continuous-improvement.mjs <report...> <spans>\");\n    process.exit(2);\n  }\n  throw e;\n}","preventionTips":["Use `--` when forwarding CLI args through npm/yarn run scripts.","Quote globs and verify they expand (`ls report*.json`) before invoking.","Wrap the validator in a script that asserts argument count.","Keep the usage comment at the top of the file in sync with CI invocations."],"tags":["cli","arguments","validation"],"backgroundTag":"missing-cli-argument","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}