jackwener/OpenCLI · error · ArgumentError
must be <= ${max}
Error message
must be <= ${max} What it means
ArgumentError thrown by normalizeInteger when an integer option exceeds its configured maximum (max defaults to Number.MAX_SAFE_INTEGER but per-option caps exist for timeouts, delays, and scroll counts). The library enforces sane upper bounds to avoid runaway scraping.
Source
Thrown at clis/grok/export-all.js:22
import {
normalizeConversationRows,
normalizeManifestRows,
requireBooleanEvaluateResult,
requireObjectEvaluateResult,
} from './export-utils.js';
import { GROK_DOMAIN, GROK_URL } from './utils.js';
function normalizeInteger(value, defaultValue, label, { min = 0, max = Number.MAX_SAFE_INTEGER } = {}) {
const raw = value ?? defaultValue;
const n = Number(raw);
if (!Number.isInteger(n)) {
throw new ArgumentError(label, `must be an integer`);
}
if (n < min) {
throw new ArgumentError(label, `must be >= ${min}`);
}
if (n > max) {
throw new ArgumentError(label, `must be <= ${max}`);
}
return n;
}
async function waitRandom(page, minMs, maxMs) {
if (maxMs <= 0) return;
const span = Math.max(0, maxMs - minMs);
const ms = minMs + Math.floor(Math.random() * (span + 1));
if (ms > 0) await page.wait(ms / 1000);
}
function readManifest(manifestPath, { offset, limit }) {
const path = String(manifestPath || '').trim();
if (!path) return null;
let parsed;
try {
parsed = JSON.parse(fs.readFileSync(path, 'utf8'));
} catch (error) {View on GitHub (pinned to 49907e53dc)
Solutions
- Use values within the documented range for each option
- Convert units correctly (seconds to ms) before passing
- Clamp with Math.min(max, value)
- Remove the override so the documented default applies
Example fix
// before
cli.exportAll({ pageTimeoutMs: 60 * 60 * 1000 }); // way above cap
// after
cli.exportAll({ pageTimeoutMs: 30 * 1000 }); Defensive patterns
Strategy: validation
Validate before calling
function clampMax(n, max) { if (n > max) throw new Error(`value ${n} must be <= ${max}`); return n; } Type guard
const isIntLte = (v, max) => Number.isInteger(v) && v <= max;
Try / catch
try { await cli.exportAll(opts); } catch (e) { if (e.name === 'ArgumentError' && /<= /.test(e.message)) { console.error(`Above maximum: ${e.message}`); } else throw e; } Prevention
- Clamp with Math.min(max, v)
- Double-check unit conversions (s vs ms) for timeouts/delays
- Don't use Number.MAX_SAFE_INTEGER as an 'unlimited' flag — omit the option instead
- Keep override values near documented defaults
When it happens
Trigger: Passing a value > max to limit/offset/maxScrolls/pageScrolls/pageTimeoutMs/delayMinMs, e.g. pageTimeoutMs=999999999.
Common situations: Misreading delay units (ms vs seconds) and passing huge values; config files with absurd timeouts; passing Number.MAX_SAFE_INTEGER as 'no limit'.
Related errors
- must be >= ${min}
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
- archive snapshots limit must be <= 1000
- archive snapshots ${key} must be a digit-only timestamp (YYY
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/27b6f7b64227c3ee.
Report an issue: GitHub.