{"record":{"id":"0af8672a86990c64","repo":"stablyai/orca","slug":"name-must-be-a-positive-integer-received-val-0af867","errorCode":null,"errorMessage":"${name} must be a positive integer, received ${value}","messagePattern":"(.+?) must be a positive integer, received (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/git-diff-blob-concurrency-benchmark.mjs","lineNumber":26,"sourceCode":"//\n// This spawns the real `git` binary against this repo, so it measures actual\n// process-launch and read cost rather than a model of it. Over SSH each diff is\n// one relay RPC and the two spawns run host-local inside the relay, so the same\n// relative saving applies to remote-host spawn time, not to network round trips.\nimport { execFile } from 'node:child_process'\nimport { performance } from 'node:perf_hooks'\nimport { fileURLToPath } from 'node:url'\n\nconst REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url))\nconst ITERATIONS = Number(process.env.ORCA_DIFF_BLOB_BENCH_ITERATIONS ?? '10')\nconst WARMUP = Number(process.env.ORCA_DIFF_BLOB_BENCH_WARMUP ?? '3')\n\nfor (const [name, value] of [\n  ['ORCA_DIFF_BLOB_BENCH_ITERATIONS', ITERATIONS],\n  ['ORCA_DIFF_BLOB_BENCH_WARMUP', WARMUP]\n]) {\n  if (!Number.isSafeInteger(value) || value <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${value}`)\n  }\n}\n\nfunction git(args) {\n  return new Promise((resolve, reject) => {\n    execFile('git', args, { cwd: REPO_ROOT, maxBuffer: 256 * 1024 * 1024 }, (error, stdout) =>\n      error ? reject(error) : resolve(stdout)\n    )\n  })\n}\n\n// Pre-fix: await one side, then the other.\nasync function readSequential(leftRef, rightRef, filePath) {\n  const left = await git(['show', '--end-of-options', `${leftRef}:${filePath}`])\n  const right = await git(['show', '--end-of-options', `${rightRef}:${filePath}`])\n  return left.length + right.length\n}\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/git-diff-blob-concurrency-benchmark.mjs#L8-L44","documentation":"Thrown at module load time when either ORCA_DIFF_BLOB_BENCH_ITERATIONS or ORCA_DIFF_BLOB_BENCH_WARMUP env var, coerced via Number(), is not a safe positive integer (<= 0, fractional, NaN, or out of safe-integer range). The check runs before any benchmarking begins (git-diff-blob-concurrency-benchmark.mjs:18-28).","triggerScenarios":"Setting ORCA_DIFF_BLOB_BENCH_ITERATIONS=0; a negative value; a fractional value like '2.5'; a non-numeric value like 'abc' (Number yields NaN); an empty string (Number yields 0); leaving it unset is fine (defaults 10/3).","commonSituations":"A CI override that sets the env to 0 to 'skip'; a typo or trailing space in the env value; a wrapper that passes a float; copy-pasting a value with units like '10x'.","solutions":["Set the env var to a positive integer, e.g. ORCA_DIFF_BLOB_BENCH_ITERATIONS=20.","Unset the env var to fall back to the defaults (iterations=10, warmup=3).","If scripting, coerce and validate before exporting: only export if Number.isSafeInteger(n) && n > 0."],"exampleFix":"# before\nexport ORCA_DIFF_BLOB_BENCH_ITERATIONS=0\n# after\nexport ORCA_DIFF_BLOB_BENCH_ITERATIONS=20  # or unset to use default 10","handlingStrategy":"validation","validationCode":"function positiveIntEnv(name, fallback) {\n  const raw = process.env[name]\n  if (raw == null || raw === '') return fallback\n  const n = Number(raw)\n  if (!Number.isSafeInteger(n) || n <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${raw}`)\n  }\n  return n\n}\nconst ITERATIONS = positiveIntEnv('ORCA_DIFF_BLOB_BENCH_ITERATIONS', 10)","typeGuard":"function isPositiveSafeInteger(value) {\n  return Number.isSafeInteger(value) && value > 0\n}","tryCatchPattern":null,"preventionTips":["Only set the env vars to whole numbers greater than zero; leave unset to use defaults.","Validate env-derived config in a shared helper before the benchmark module loads."],"tags":["environment","argument-validation","benchmark"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}