{"record":{"id":"86c4288a9b434936","repo":"stablyai/orca","slug":"name-must-be-a-positive-integer-received-val","errorCode":null,"errorMessage":"${name} must be a positive integer, received ${value}","messagePattern":"(.+?) must be a positive integer, received (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/advertised-url-watcher-benchmark.mjs","lineNumber":59,"sourceCode":"  }\n}\n\nconst { AdvertisedUrlWatcher, extractUrlCandidates, stripTerminalControls } = await import(\n  new URL('../../src/main/ports/advertised-url-watcher.ts', import.meta.url).href\n)\n\nconst BUFFER_LIMIT = 4096\nconst ITERATIONS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ITERATIONS ?? '10000')\nconst ROUNDS = Number(process.env.ORCA_ADVERTISED_URL_BENCH_ROUNDS ?? '12')\nconst WARMUP = Number(process.env.ORCA_ADVERTISED_URL_BENCH_WARMUP ?? '1000')\n\nfor (const [name, value] of [\n  ['ORCA_ADVERTISED_URL_BENCH_ITERATIONS', ITERATIONS],\n  ['ORCA_ADVERTISED_URL_BENCH_ROUNDS', ROUNDS],\n  ['ORCA_ADVERTISED_URL_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}\nif (ROUNDS % 2 !== 0) {\n  throw new Error('ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even')\n}\n\nclass BeforePtyBuffer {\n  raw = ''\n\n  ingest(chunk) {\n    const chunkHasLineBreak = chunk.includes('\\n') || chunk.includes('\\r')\n    this.raw += chunk\n    if (this.raw.length > BUFFER_LIMIT) {\n      this.raw = this.raw.slice(-BUFFER_LIMIT)\n    }\n    if (!chunkHasLineBreak) {\n      return ''\n    }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/advertised-url-watcher-benchmark.mjs#L41-L77","documentation":"Thrown by the advertised-url-watcher benchmark when one of ORCA_ADVERTISED_URL_BENCH_ITERATIONS / _ROUNDS / _WARMUP is not a safe positive integer. Number(env) is used, so non-numeric strings become NaN, decimals become floats, and oversized values exceed Number.isSafeInteger — each is rejected because the timing loops need integer counts.","triggerScenarios":"Setting ORCA_ADVERTISED_URL_BENCH_ITERATIONS=10000.5 (float), =1e21 (exceeds MAX_SAFE_INTEGER), =abc (NaN), =0 or negative, or unsetting and overriding with an empty string.","commonSituations":"Operator typo in a CI workflow env block; copying a value from another benchmark without adjusting precision; attempting a stress run with an absurd iteration count.","solutions":["Set each env var to a positive integer within Number.MAX_SAFE_INTEGER, e.g. ORCA_ADVERTISED_URL_BENCH_ITERATIONS=10000 ORCA_ADVERTISED_URL_BENCH_ROUNDS=12 ORCA_ADVERTISED_URL_BENCH_WARMUP=1000.","If unset, the defaults (10000/12/1000) are correct — remove the override entirely.","Validate the env in the workflow with a regex (^[1-9][0-9]*$) before invoking the benchmark.","For very large stress runs, scale ROUNDS rather than ITERATIONS to stay within safe-integer range."],"exampleFix":"// before\n// ORCA_ADVERTISED_URL_BENCH_ITERATIONS=1e21 node config/scripts/advertised-url-watcher-benchmark.mjs\n// -> 'ORCA_ADVERTISED_URL_BENCH_ITERATIONS must be a positive integer, received 1e+21'\n\n// after\n// ORCA_ADVERTISED_URL_BENCH_ITERATIONS=20000 node config/scripts/advertised-url-watcher-benchmark.mjs","handlingStrategy":"validation","validationCode":"function readPositiveIntEnv(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 safe integer, got '${raw}'`)\n  }\n  return n\n}\n// const ITERATIONS = readPositiveIntEnv('ORCA_ADVERTISED_URL_BENCH_ITERATIONS', 10000)","typeGuard":"function isPositiveSafeInteger(value) {\n  return Number.isSafeInteger(value) && value > 0\n}","tryCatchPattern":null,"preventionTips":["Prefer unsetting the env var to use defaults rather than overriding with a near-equivalent.","Validate env values in the CI workflow with ^[1-9][0-9]*$ before invoking the benchmark.","Keep iteration counts within Number.MAX_SAFE_INTEGER; scale rounds rather than iterations for stress runs."],"tags":["benchmark","env-var","validation","integer","advertised-url"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}