jackwener/OpenCLI · error · ArgumentError

limit must be a positive integer ≤ ${max}

Error message

limit must be a positive integer ≤ ${max}

What it means

ArgumentError thrown by validatedLimit() when the provided limit is not a finite integer between 1 and max (default 1000). The CLI mirrors the Connect-RPC/Buf Validate server rules client-side so users get a clear error without a wasted round-trip.

Source

Thrown at clis/manus/_utils.js:32

    try {
        const url = new URL(String(value || ''));
        const host = url.hostname.toLowerCase();
        return url.protocol === 'https:' && (host === MANUS_DOMAIN || host === `www.${MANUS_DOMAIN}`);
    } catch {
        return false;
    }
}

/**
 * Validate a `--limit N` argument: must be a positive integer ≤ `max`.
 * Negatives, zero, NaN, Infinity, and non-integers all reject. Manus's
 * Connect-RPC backend enforces these server-side via Buf Validate; failing
 * client-side gives the user a clearer error and skips a wasted round-trip.
 */
export function validatedLimit(raw, fallback, max = 1000) {
    const n = raw == null ? fallback : Number(raw);
    if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1 || n > max) {
        throw new ArgumentError('limit', `must be a positive integer ≤ ${max}`);
    }
    return n;
}

export function unwrapEvaluateResult(payload) {
    if (
        payload
        && typeof payload === 'object'
        && !Array.isArray(payload)
        && Object.prototype.hasOwnProperty.call(payload, 'session')
        && Object.prototype.hasOwnProperty.call(payload, 'data')
    ) {
        return payload.data;
    }
    return payload;
}

function extractErrorMessage(payload) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass an integer between 1 and 1000, e.g. --limit 100.
  2. Omit --limit to use the built-in fallback default.
  3. In scripts, Math.floor/parseInt the value and clamp: Math.min(Math.max(1, n), 1000).
  4. If you need more than max results, paginate instead of raising limit.

Example fix

// before
manus sessions --limit 0
// after
manus sessions --limit 100
Defensive patterns

Strategy: validation

Validate before calling

function clampLimit(raw, max = 1000) {
  const n = Number(raw);
  if (!Number.isInteger(n) || n < 1 || n > max) throw new RangeError(`limit must be an integer 1..${max}`);
  return n;
}

Type guard

function isValidLimit(v, max = 1000) { return Number.isInteger(v) && v >= 1 && v <= max; }

Try / catch

try {
  const sessions = await manusSessions({ limit });
} catch (e) {
  if (/limit must be a positive integer/.test(e.message)) {
    console.error(`--limit must be an integer 1..1000, got: ${limit}`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Calling a list-style manus command (sessions, connectors, skills) with --limit 0, a negative number, a float, a non-numeric string, or a value above max; omitting raw while fallback itself is invalid is not possible since fallback defaults are valid.

Common situations: Passing --limit 0 expecting 'unlimited', copy-pasting limits like 5000 from other CLIs, quoting '10 ' or 'ten', scripts computing limit via division producing floats.

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


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