jackwener/OpenCLI · error · ArgumentError
${label} must be a positive integer
Error message
${label} must be a positive integer What it means
ArgumentError thrown by parsePositiveInt when a numeric option (limit, timeoutSec) is not a positive integer. Non-numeric strings become NaN and fail the Number.isInteger check; zero, negatives, and floats are also rejected. Empty/null falls back to the provided default rather than throwing.
Source
Thrown at clis/qoder/_utils.js:48
}
return payload;
}
export async function evaluateQoder(page, script) {
return unwrapEvaluateResult(await page.evaluate(script));
}
export function requireArrayResult(value, label) {
if (!Array.isArray(value)) {
throw new CommandExecutionError(`${label}: unexpected evaluate result shape`);
}
return value;
}
export function parsePositiveInt(raw, fallback, label) {
const value = raw == null || raw === '' ? fallback : Number(raw);
if (!Number.isInteger(value) || value < 1) {
throw new ArgumentError(`${label} must be a positive integer`);
}
return value;
}
// Build a JS snippet that clicks the first visible element matching any
// of the given CSS selectors. Uses the full pointer-event chain to
// satisfy radix/headless menu libraries.
export function clickFirstScript(selectors) {
return `(() => {
${IS_VISIBLE_JS}
const sels = ${JSON.stringify(selectors)};
for (const sel of sels) {
const target = Array.from(document.querySelectorAll(sel)).filter(isVisible)[0];
if (target) {
const r = target.getBoundingClientRect();
const opts = { bubbles: true, cancelable: true, clientX: r.x + r.width/2, clientY: r.y + r.height/2 };
target.dispatchEvent(new PointerEvent('pointerdown', opts));
target.dispatchEvent(new MouseEvent('mousedown', opts));View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a plain positive integer, e.g. `--limit 10 --timeoutSec 30`
- Omit the option entirely to use the built-in default
- Validate numeric flags in wrapper scripts before invoking the CLI
Example fix
// before
spawn('qoder', ['items', '--limit', '0']); // throws
// after
spawn('qoder', ['items', '--limit', '10']); Defensive patterns
Strategy: validation
Validate before calling
function assertPositiveInt(v) {
const n = Number(v);
if (!Number.isInteger(n) || n < 1) throw new Error(`${v} is not a positive integer`);
return n;
}
assertPositiveInt(opts.limit); Type guard
function isPositiveInt(v) { return Number.isInteger(v) && v >= 1; } Try / catch
try {
await qoderItems({ limit: rawLimit });
} catch (e) {
if (/must be a positive integer/.test(e.message)) {
console.error('Pass an integer >= 1 for --limit/--timeoutSec, or omit for the default');
} else throw e;
} Prevention
- Validate numeric flags at the script boundary before spawning the CLI
- Never pass 0 or unit-suffixed values ('30s') expecting them to be coerced
- Rely on built-in defaults by omitting optional numeric flags
When it happens
Trigger: Calling a qoder command with `--limit 0`, `--limit -5`, `--limit abc`, `--limit 2.5`, or `--timeoutSec 0`; passing a value with units ('30s') or whitespace-padded strings that Number() can't cleanly coerce.
Common situations: Shell variables containing invalid values; documentation examples copy-pasted with unit suffixes; users assuming 0 means 'unlimited'; locale-formatted numbers with commas.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- bbc topic "${args.topic}" is not supported
- bbc ${label} must be a positive integer
- bbc ${label} must be <= ${maxValue}
- ARGUMENT
- ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e05fee7389cf8c8a.
Report an issue: GitHub.