tinyhumansai/openhuman · error · Error
${label} must be a positive integer
Error message
${label} must be a positive integer What it means
parsePositiveInt() coerces the raw string with Number() and requires an integer >= 1; otherwise it throws with the flag's label. In harness-cache-audit.mjs it guards --turns and --rpc-timeout-ms. It exists because zero/negative/fractional values for these knobs are nonsensical (a zero-turn audit or a zero-ms timeout would hang or trivially abort every RPC).
Source
Thrown at scripts/debug/harness-cache-audit.mjs:138
break;
case "--verbose":
opts.verbose = true;
break;
case "-h":
case "--help":
console.log(usage());
process.exit(0);
default:
throw new Error(`unknown option: ${arg}`);
}
}
return opts;
}
function parsePositiveInt(raw, label) {
const value = Number(raw);
if (!Number.isInteger(value) || value < 1)
throw new Error(`${label} must be a positive integer`);
return value;
}
function parseNonNegativeInt(raw, label) {
const value = Number(raw);
if (!Number.isInteger(value) || value < 0)
throw new Error(`${label} must be a non-negative integer`);
return value;
}
function parseNonNegativeNumber(raw, label) {
const value = Number(raw);
if (!Number.isFinite(value) || value < 0)
throw new Error(`${label} must be a non-negative number`);
return value;
}
function defaultOpenhumanDir() {View on GitHub (pinned to a221052e0d)
Solutions
- Pass a plain integer >= 1: `--turns 4`, `--rpc-timeout-ms 900000`
- For 'as fast as possible' use 1, not 0
- Remove underscores/commas/units from the value
- Echo the variable in wrappers before composing the command to catch empty expansions
Example fix
# before node scripts/debug/harness-cache-audit.mjs --turns 0 # Error: --turns must be a positive integer # after node scripts/debug/harness-cache-audit.mjs --turns 1
Defensive patterns
Strategy: validation
Validate before calling
const toPositiveInt = (raw, label) => {
const n = Number(raw);
if (!Number.isInteger(n) || n < 1) {
console.error(`${label} must be an integer >= 1 (got: ${raw})`);
process.exit(2);
}
return n;
};
const turns = toPositiveInt(process.env.AUDIT_TURNS ?? "3", "--turns"); Type guard
const isPositiveIntString = (s) => /^[1-9]\d*$/.test(String(s).trim());
Prevention
- Write thresholds as plain decimal integers; no underscores, commas, units, or percent signs
- Remember 0 is invalid for --turns/--rpc-timeout-ms but valid for --max-turns-without-cache — the two validators differ
When it happens
Trigger: `--turns 0` (zero turns), `--turns 3.5`, `--turns abc` (Number() → NaN fails Number.isInteger), `--rpc-timeout-ms 0`, `--rpc-timeout-ms 10_000` (underscore is not numeric in Number()), or scientific-notation strings like `1e3` — technically valid to Number() but usually a typo intent.
Common situations: Trying to disable something by setting it to 0; paste from docs with underscores; locale decimal comma (3,5 → parsed as 3 then trailing garbage or NaN); math in shell like `--turns $((2+2))` producing empty on error.
Related errors
- ${label} must be a non-negative integer
- ${label} must be a non-negative number
- Failed to parse service CLI output as JSON: parsed value doe
- paths must be repo-relative, not absolute (got "${p}")
- must be an array
AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16).
Data as JSON: /api/errors/fe382856999a25ac.
Report an issue: GitHub.