jackwener/OpenCLI · warning · ArgumentError

--limit must be an integer between 1 and ${MAX_LIMIT}

Error message

--limit must be an integer between 1 and ${MAX_LIMIT}

What it means

An ArgumentError from the shared parseLimit helper: the --limit argument was supplied but is not an integer in the range 1..MAX_LIMIT (50). parseLimit returns a default of 10 when the value is undefined/null/empty, so this only fires on explicit but invalid input such as 0, -5, 'abc', 3.5, or 51.

Source

Thrown at clis/linkedin-learning/shared.js:14

import { ArgumentError, AuthRequiredError } from '@jackwener/opencli/errors';

export const DOMAIN = 'www.linkedin.com';
export const MAX_LIMIT = 50;

export function normalizeWhitespace(value) {
    return String(value ?? '').replace(/[  ]/g, ' ').replace(/\s+/g, ' ').trim();
}

export function parseLimit(value) {
    if (value === undefined || value === null || value === '') return 10;
    const limit = Number(value);
    if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
        throw new ArgumentError(`--limit must be an integer between 1 and ${MAX_LIMIT}`);
    }
    return limit;
}

export function unwrapEvaluateResult(payload) {
    if (payload && typeof payload === 'object' && 'data' in payload && 'session' in payload) return payload.data;
    return payload;
}

export function buildFetchScript(url, csrf) {
    return String.raw`(async () => {
    try {
      const res = await fetch(${JSON.stringify(url)}, {
        credentials: 'include',
        headers: {
          'csrf-token': ${JSON.stringify(csrf)},
          'x-restli-protocol-version': '2.0.0',
          accept: 'application/json',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass an integer between 1 and 50, or omit --limit to use the default of 10.
  2. Coerce/validate the value in your wrapper script before invoking the CLI.
  3. Use Math.trunc for floats and clamp to [1, 50].
  4. Check the command help (args.help) for the documented range.

Example fix

// before
clio linkedin-learning search --keywords js --limit 100
// after
clio linkedin-learning search --keywords js --limit 50
Defensive patterns

Strategy: validation

Validate before calling

function sanitizeLimit(v) {
  if (v === undefined || v === null || v === '') return 10;
  const n = Math.trunc(Number(v));
  if (!Number.isFinite(n)) throw new Error(`--limit must be a number, got: ${v}`);
  return Math.min(Math.max(n, 1), 50);
}
// usage: --limit $(sanitizeLimit "$LIMIT")

Type guard

function isValidLimit(v) {
  if (v === undefined || v === null || v === '') return true;
  const n = Number(v);
  return Number.isInteger(n) && n >= 1 && n <= 50;
}

Try / catch

try {
  await run(['linkedin-learning', 'search', '--keywords', kw, '--limit', String(limit)]);
} catch (e) {
  if (e.message.startsWith('--limit must be')) {
    limit = 10; // fall back to default and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Passing --limit 0 or a negative number, a non-numeric string (--limit ten), a float (--limit 2.5, Number() yields NaN or a non-integer), or a value above MAX_LIMIT=50.

Common situations: Scripting the CLI with an unvalidated variable that is empty-but-not-null (e.g. string '0'), typos in shell scripts, users assuming the cap is unlimited, or passing float values from JSON config.

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/a3e709de927b01b6. Report an issue: GitHub.