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 branch-compare-head benchmark when ORCA_BRANCH_COMPARE_BENCH_ITERATIONS or _WARMUP is not a safe positive integer. Uses Number(env) and Number.isSafeInteger, so NaN (non-numeric/empty), floats, zero/negative, and values beyond MAX_SAFE_INTEGER all fail. Defaults are 8 iterations and 2 warmup because each iteration spawns many git processes.
Source
Thrown at config/scripts/branch-compare-head-benchmark.mjs:32
// Both arms are compared for identical resolved values before timing.
//
// Run with: node config/scripts/branch-compare-head-benchmark.mjs
import { execFile } from 'node:child_process'
import { performance } from 'node:perf_hooks'
import { fileURLToPath } from 'node:url'
import { readBranchCompareHead } from '../../src/shared/git-branch-compare-head.ts'
const REPO_ROOT = fileURLToPath(new URL('../..', import.meta.url))
const ITERATIONS = Number(process.env.ORCA_BRANCH_COMPARE_BENCH_ITERATIONS ?? '8')
const WARMUP = Number(process.env.ORCA_BRANCH_COMPARE_BENCH_WARMUP ?? '2')
const ROUNDS = 6
for (const [name, value] of [
['ORCA_BRANCH_COMPARE_BENCH_ITERATIONS', ITERATIONS],
['ORCA_BRANCH_COMPARE_BENCH_WARMUP', WARMUP]
]) {
if (!Number.isSafeInteger(value) || value <= 0) {
throw new Error(`${name} must be a positive integer, received ${value}`)
}
}
function git(args) {
return new Promise((resolve, reject) => {
execFile('git', args, { cwd: REPO_ROOT, maxBuffer: 64 * 1024 * 1024 }, (error, stdout) =>
error ? reject(error) : resolve(stdout.trim())
)
})
}
async function probeOid(qualifiedRef) {
try {
const out = await git(['rev-parse', '--verify', '--quiet', `${qualifiedRef}^{commit}`])
return out.length > 0 ? out : null
} catch {
return null
}View on GitHub (pinned to 1136503c6a)
Solutions
- Set each env var to a positive integer, e.g. ORCA_BRANCH_COMPARE_BENCH_ITERATIONS=8 ORCA_BRANCH_COMPARE_BENCH_WARMUP=2 (defaults).
- Unset both to use the defaults — note each iteration spawns ~8 git processes so larger values are slow.
- Validate in CI with ^[1-9][0-9]*$ before running.
- Keep iterations modest (<=50) — this benchmark times real git spawns, so wall-clock grows linearly.
Example fix
// before // ORCA_BRANCH_COMPARE_BENCH_ITERATIONS='' node config/scripts/branch-compare-head-benchmark.mjs // -> 'ORCA_BRANCH_COMPARE_BENCH_ITERATIONS must be a positive integer, received NaN' // after // unset ORCA_BRANCH_COMPARE_BENCH_ITERATIONS // node config/scripts/branch-compare-head-benchmark.mjs
Defensive patterns
Strategy: validation
Validate before calling
function readPositiveSafeIntEnv(name, fallback) {
const raw = process.env[name]
if (raw == null || raw === '') return fallback
const n = Number(raw)
if (!Number.isSafeInteger(n) || n <= 0) {
throw new Error(`${name} must be a positive safe integer, got '${raw}'`)
}
return n
}
// const ITERATIONS = readPositiveSafeIntEnv('ORCA_BRANCH_COMPARE_BENCH_ITERATIONS', 8) Type guard
function isPositiveSafeInteger(value) {
return Number.isSafeInteger(value) && value > 0
} Prevention
- Prefer unsetting the env var to use the defaults (8/2) — each iteration spawns ~8 git processes.
- Keep iteration counts modest (<=50); this benchmark times real git spawns and wall-clock is linear.
- Validate env in CI with ^[1-9][0-9]*$.
When it happens
Trigger: Setting ORCA_BRANCH_COMPARE_BENCH_ITERATIONS to a non-numeric string, a float, zero, or a very large number; unsetting and the env layer returned an empty string instead of undefined.
Common situations: Operator bumps iterations to '100' for a longer run but typos to '1o0'; CI matrix injects an empty string for an unset var; attempting to scale iterations high enough to exceed MAX_SAFE_INTEGER.
Related errors
- ${name} must be a positive integer, received ${value}
- ${name} must be a positive integer, received ${value}
- ORCA_ADVERTISED_URL_BENCH_ROUNDS must be even
- no benchmark file exists at both HEAD and HEAD~1 in this che
- ORCA_REPLAY_BENCH_SECONDS must be positive, received ${SECON
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/33a16024fa07dbb4.
Report an issue: GitHub.