stablyai/orca · error · Error
--trials must be a positive integer
Error message
--trials must be a positive integer
What it means
The --trials value fails Number.isInteger() or is less than 1. The default is DEFAULT_TRIALS (3), so this only fires when --trials is explicitly provided with an invalid value. Floats, zero, negatives, NaN, and non-numeric strings all fail.
Source
Thrown at config/scripts/macos-computer-helper-owner-loss-benchmark.mjs:409
const options = { expect: '', trials: DEFAULT_TRIALS, output: '' }
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index]
const value = argv[index + 1]
if (arg === '--expect' || arg === '--trials' || arg === '--output') {
if (!value) {
throw new Error(`Missing value for ${arg}`)
}
options[arg.slice(2)] = arg === '--trials' ? Number(value) : value
index += 1
} else {
throw new Error(`Unknown argument: ${arg}`)
}
}
if (!['retained', 'reaped'].includes(options.expect)) {
throw new Error('--expect must be retained or reaped')
}
if (!Number.isInteger(options.trials) || options.trials < 1) {
throw new Error('--trials must be a positive integer')
}
return options
}
function electronPath() {
const electronModulePath = fileURLToPath(import.meta.resolve('electron'))
return execFileSync(
process.execPath,
['-e', `process.stdout.write(require(${JSON.stringify(electronModulePath)}))`],
{ encoding: 'utf8' }
)
}
function buildArtifacts() {
execFileSync('pnpm', ['exec', 'electron-vite', 'build'], {
cwd: repoRoot,
stdio: 'inherit'
})View on GitHub (pinned to 1136503c6a)
Solutions
- Pass a positive integer: `--trials 3`
- If computing trials programmatically, use Math.floor and clamp to >= 1 before passing
Example fix
// before node benchmark.mjs --expect reaped --trials 2.5 // after node benchmark.mjs --expect reaped --trials 3
Defensive patterns
Strategy: validation
Validate before calling
// Validate --trials before parsing
const trialsIndex = argv.indexOf('--trials')
if (trialsIndex !== -1) {
const n = Number(argv[trialsIndex + 1])
if (!Number.isInteger(n) || n < 1) {
throw new Error(`--trials must be a positive integer, got: ${argv[trialsIndex + 1]}`)
}
} Type guard
function isPositiveInteger(value) {
return Number.isInteger(value) && value >= 1
} Prevention
- Pass an integer literal, not a float or expression
- If computing trials programmatically, use Math.floor and Math.max(1, ...)
- Validate in wrapper scripts before delegating
When it happens
Trigger: options.trials is not a positive integer at line 408. Number('2.5') = 2.5 (not integer), Number('0') = 0 (< 1), Number('abc') = NaN (not finite → not integer), Number('-1') = -1 (< 1).
Common situations: Passing a float like --trials 2.5; passing zero or negative; passing a non-numeric string; shell arithmetic producing a float.
Related errors
- --higher-is-better requires a metric key
- Usage: node config/scripts/compare-benchmark-artifacts.mjs -
- Missing value for ${arg}
- Unknown argument: ${arg}
- --boundary must be child or worker
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/d5a42d3590e153e6.
Report an issue: GitHub.