stablyai/orca · error

${name} must be a positive integer, received ${value}

Error message

${name} must be a positive integer, received ${value}

What it means

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.

Source

Thrown at config/scripts/agent-hook-normalizer-roundtrip-benchmark.mjs:49

  if (!match) {
    throw new Error(`agent-status-types.ts no longer defines ${name}; re-sync this benchmark.`)
  }
  return Number(match[1].replaceAll('_', ''))
}

// Read the cap the direct path clamps at, so a drifted value fails loudly here
// instead of quietly changing what this benchmark claims.
const ASSISTANT_MESSAGE_CAP = readMirroredConstant('AGENT_STATUS_ASSISTANT_MESSAGE_MAX_LENGTH')

const ITERATIONS = Number.parseInt(process.env.ORCA_HOOK_NORM_BENCH_ITERATIONS ?? '400', 10)
const WARMUP = Number.parseInt(process.env.ORCA_HOOK_NORM_BENCH_WARMUP ?? '200', 10)

for (const [name, value] of [
  ['ORCA_HOOK_NORM_BENCH_ITERATIONS', ITERATIONS],
  ['ORCA_HOOK_NORM_BENCH_WARMUP', WARMUP]
]) {
  if (!Number.isInteger(value) || value <= 0) {
    throw new Error(`${name} must be a positive integer, received ${value}`)
  }
}

const STRUCTURAL_TOKENS = 4096
const NESTING_DEPTH = 16

// Mirror of assertJsonTextStructureWithinLimits — the per-character scan the
// round trip pays before JSON.parse even starts.
function scanJsonStructure(content) {
  let structuralTokens = 0
  let depth = 0
  let inString = false
  let escaped = false
  for (let index = 0; index < content.length; index += 1) {
    const character = content[index]
    if (inString) {
      if (escaped) {
        escaped = false

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Set the env var to a positive integer string, e.g. ORCA_HOOK_NORM_BENCH_ITERATIONS=400 ORCA_HOOK_NORM_BENCH_WARMUP=200.
  2. Unset both to use the defaults (400/200).
  3. Validate in the workflow with ^[1-9][0-9]*$ before invoking.
  4. Note parseInt silently truncates decimals — if strictness is desired, switch to Number(...) + Number.isSafeInteger like the other benchmarks.

Example fix

// before
// ORCA_HOOK_NORM_BENCH_ITERATIONS=0 node config/scripts/agent-hook-normalizer-roundtrip-benchmark.mjs
// -> 'ORCA_HOOK_NORM_BENCH_ITERATIONS must be a positive integer, received 0'

// after
// ORCA_HOOK_NORM_BENCH_ITERATIONS=400 node config/scripts/agent-hook-normalizer-roundtrip-benchmark.mjs
Defensive patterns

Strategy: validation

Validate before calling

function readPositiveIntEnv(name, fallback) {
  const raw = process.env[name]
  if (raw == null || raw === '') return fallback
  const n = Number.parseInt(raw, 10)
  if (!Number.isInteger(n) || n <= 0) {
    throw new Error(`${name} must be a positive integer, got '${raw}'`)
  }
  return n
}
// const ITERATIONS = readPositiveIntEnv('ORCA_HOOK_NORM_BENCH_ITERATIONS', 400)

Type guard

function isPositiveInteger(value) {
  return Number.isInteger(value) && value > 0
}

Prevention

When it happens

Trigger: Setting ORCA_HOOK_NORM_BENCH_ITERATIONS to 'abc' (NaN via parseInt), '' (NaN), '0', or a negative number.

Common situations: Typo in CI env; copying a float default; unsetting with the intent of using defaults but a wrapper set an empty string instead.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/647af18ca57e17ae. Report an issue: GitHub.