jackwener/OpenCLI · error · ArgumentError

must be >= ${min}

Error message

must be >= ${min}

What it means

ArgumentError thrown by normalizeInteger when an integer option is below its configured minimum. Each option (limit, offset, maxScrolls, pageScrolls, pageTimeoutMs, delayMinMs) carries a min bound; negative or too-small values are rejected before the scrape starts.

Source

Thrown at clis/grok/export-all.js:19

import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, EmptyResultError, TimeoutError } from '@jackwener/opencli/errors';
import fs from 'node:fs';
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;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Clamp the value with Math.max(min, value) before calling
  2. Use 0 or the documented minimum for offset/limit
  3. Check your offset pagination math for sign errors
  4. Inspect each option's min bound and supply a compliant value

Example fix

// before
cli.exportAll({ offset: -1 });
// after
cli.exportAll({ offset: Math.max(0, computedOffset) });
Defensive patterns

Strategy: validation

Validate before calling

function clampMin(n, min) { if (n < min) throw new Error(`value ${n} must be >= ${min}`); return n; }

Type guard

const isIntGte = (v, min) => Number.isInteger(v) && v >= min;

Try / catch

try { await cli.exportAll(opts); } catch (e) { if (e.name === 'ArgumentError' && />= /.test(e.message)) { console.error(`Below minimum: ${e.message}`); } else throw e; }

Prevention

When it happens

Trigger: Passing a value < min to any validated option, e.g. offset=-1, maxScrolls=-5, or a below-minimum pageTimeoutMs/delayMinMs.

Common situations: Negative offsets computed as prevOffset-offset without clamping; scripts computing timeouts from metrics that can be 0/negative; typos like --offset=-10.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2b801967532f83de. Report an issue: GitHub.