tinyhumansai/openhuman · error · Error
${label} must be a positive integer
Error message
${label} must be a positive integer What it means
parsePositiveInt() in scripts/debug/agent-prepare-context-audit.mjs coerces a raw CLI string with Number() and rejects anything that is not an integer >= 1 — NaN (non-numeric text), 0, negatives, and fractional values all throw '<label> must be a positive integer'. It guards numeric options such as --max-print-chars and --rpc-timeout-ms before they can poison later math.
Source
Thrown at scripts/debug/agent-prepare-context-audit.mjs:187
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 defaultOpenhumanDir() {
if (process.env.OPENHUMAN_APP_ENV === "staging") {
return path.join(homedir(), ".openhuman-staging");
}
if (process.env.OPENHUMAN_APP_ENV) {
return path.join(homedir(), ".openhuman");
}
// APP_ENV unset: the core (launched from a shell that may export
// OPENHUMAN_APP_ENV=staging) and this script can disagree. Auto-pick the
// dir whose active_user.toml was touched most recently so transcript reads
// land in the same env the core actually uses. Falls back to prod.
const prod = path.join(homedir(), ".openhuman");
const staging = path.join(homedir(), ".openhuman-staging");
const mtime = (p) => {
try {View on GitHub (pinned to a221052e0d)
Solutions
- Pass a plain decimal integer >= 1, e.g. --rpc-timeout-ms 1200000
- To raise limits, pick a larger value rather than 0 — 0 is intentionally invalid
- For 'unbounded' printing, pass a very large --max-print-chars instead of 0
Example fix
# before $ node scripts/debug/agent-prepare-context-audit.mjs --max-print-chars 0 Error: --max-print-chars must be a positive integer # after $ node scripts/debug/agent-prepare-context-audit.mjs --max-print-chars 1000000
Defensive patterns
Strategy: validation
Validate before calling
function assertPositiveInt(raw, label) {
const n = Number(raw);
if (!Number.isInteger(n) || n < 1) throw new Error(`${label} must be a positive integer (got ${raw})`);
return n;
}
const rawTimeout = argv.find((_, i) => argv[i - 1] === "--rpc-timeout-ms") ?? "600000";
assertPositiveInt(rawTimeout, "--rpc-timeout-ms"); Type guard
function isPositiveInt(raw) {
const n = Number(raw);
return Number.isInteger(n) && n >= 1;
} Prevention
- Remember 0 is intentionally invalid — there is no 'disable' value for these options
- Pass plain decimal integers; human units like 10m are not parsed
- Encode the floor in wrapper scripts so bad values fail before the audit starts
When it happens
Trigger: Passing --rpc-timeout-ms 0, --max-print-chars 1.5, or a non-numeric value like --rpc-timeout-ms 10min. Number('') is 0, so an empty value also fails here — but an absent value fails earlier with 'missing value'.
Common situations: Trying to disable truncation with --max-print-chars 0; expressing timeouts in human units ('10m') the parser can't read; passing 0 expecting 'no timeout' when the semantics require >= 1.
Related errors
- missing value for ${arg}
- unknown option: ${arg}
- --scenario must be one of ${Array.from(scenarios).join(", ")
- --provider-mode must be one of ${Array.from(providerModes).j
- ${label} must be a positive integer
AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16).
Data as JSON: /api/errors/ed061c5d4e727f29.
Report an issue: GitHub.