{"record":{"id":"647af18ca57e17ae","repo":"stablyai/orca","slug":"name-must-be-a-positive-integer-received-val-647af1","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/agent-hook-normalizer-roundtrip-benchmark.mjs","lineNumber":49,"sourceCode":"  if (!match) {\n    throw new Error(`agent-status-types.ts no longer defines ${name}; re-sync this benchmark.`)\n  }\n  return Number(match[1].replaceAll('_', ''))\n}\n\n// Read the cap the direct path clamps at, so a drifted value fails loudly here\n// instead of quietly changing what this benchmark claims.\nconst ASSISTANT_MESSAGE_CAP = readMirroredConstant('AGENT_STATUS_ASSISTANT_MESSAGE_MAX_LENGTH')\n\nconst ITERATIONS = Number.parseInt(process.env.ORCA_HOOK_NORM_BENCH_ITERATIONS ?? '400', 10)\nconst WARMUP = Number.parseInt(process.env.ORCA_HOOK_NORM_BENCH_WARMUP ?? '200', 10)\n\nfor (const [name, value] of [\n  ['ORCA_HOOK_NORM_BENCH_ITERATIONS', ITERATIONS],\n  ['ORCA_HOOK_NORM_BENCH_WARMUP', WARMUP]\n]) {\n  if (!Number.isInteger(value) || value <= 0) {\n    throw new Error(`${name} must be a positive integer, received ${value}`)\n  }\n}\n\nconst STRUCTURAL_TOKENS = 4096\nconst NESTING_DEPTH = 16\n\n// Mirror of assertJsonTextStructureWithinLimits — the per-character scan the\n// round trip pays before JSON.parse even starts.\nfunction scanJsonStructure(content) {\n  let structuralTokens = 0\n  let depth = 0\n  let inString = false\n  let escaped = false\n  for (let index = 0; index < content.length; index += 1) {\n    const character = content[index]\n    if (inString) {\n      if (escaped) {\n        escaped = false","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/agent-hook-normalizer-roundtrip-benchmark.mjs#L31-L67","documentation":"Thrown by the agent-hook-normalizer benchmark when ORCA_HOOK_NORM_BENCH_ITERATIONS or _WARMUP is not a positive integer. Unlike the advertised-url benchmark, this uses Number.parseInt(...,10) so a float is truncated (1.9 -> 1) and only fails if NaN or <=0; the guard uses Number.isInteger (not isSafeInteger) so very large values are accepted here.","triggerScenarios":"Setting ORCA_HOOK_NORM_BENCH_ITERATIONS to 'abc' (NaN via parseInt), '' (NaN), '0', or a negative number.","commonSituations":"Typo in CI env; copying a float default; unsetting with the intent of using defaults but a wrapper set an empty string instead.","solutions":["Set the env var to a positive integer string, e.g. ORCA_HOOK_NORM_BENCH_ITERATIONS=400 ORCA_HOOK_NORM_BENCH_WARMUP=200.","Unset both to use the defaults (400/200).","Validate in the workflow with ^[1-9][0-9]*$ before invoking.","Note parseInt silently truncates decimals — if strictness is desired, switch to Number(...) + Number.isSafeInteger like the other benchmarks."],"exampleFix":"// before\n// ORCA_HOOK_NORM_BENCH_ITERATIONS=0 node config/scripts/agent-hook-normalizer-roundtrip-benchmark.mjs\n// -> 'ORCA_HOOK_NORM_BENCH_ITERATIONS must be a positive integer, received 0'\n\n// after\n// ORCA_HOOK_NORM_BENCH_ITERATIONS=400 node config/scripts/agent-hook-normalizer-roundtrip-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.parseInt(raw, 10)\n  if (!Number.isInteger(n) || n <= 0) {\n    throw new Error(`${name} must be a positive integer, got '${raw}'`)\n  }\n  return n\n}\n// const ITERATIONS = readPositiveIntEnv('ORCA_HOOK_NORM_BENCH_ITERATIONS', 400)","typeGuard":"function isPositiveInteger(value) {\n  return Number.isInteger(value) && value > 0\n}","tryCatchPattern":null,"preventionTips":["Use the defaults (400/200) unless you have a reason to override.","Note that parseInt truncates floats silently — if strictness matters, switch to Number() + Number.isSafeInteger.","Validate env in CI with ^[1-9][0-9]*$."],"tags":["benchmark","env-var","validation","integer","agent-status"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}