jackwener/OpenCLI · error · ArgumentError

--limit must be an integer between ${MIN_LIMIT} and ${MAX_LI

Error message

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

What it means

The `linkedin inbox` command validates `--limit` explicitly instead of silently clamping. If the value is provided but is not an integer (or not parseable as one) or falls outside [MIN_LIMIT, MAX_LIMIT], an ArgumentError is thrown before any navigation happens. This is fail-fast input validation so out-of-range requests are surfaced rather than quietly altered.

Source

Thrown at clis/linkedin/inbox.js:161

  ],
  columns: [
    'rank',
    'thread_url',
    'thread_id',
    'person_name',
    'last_message_preview',
    'unread',
    'counterparty_type',
    'category',
    'timestamp',
  ],
  func: async (page, kwargs) => {
    // Validate --limit explicitly rather than silently clamping an out-of-range value.
    let limit = DEFAULT_LIMIT;
    if (kwargs.limit !== undefined && kwargs.limit !== null && kwargs.limit !== '') {
      limit = Number(kwargs.limit);
      if (!Number.isInteger(limit) || limit < MIN_LIMIT || limit > MAX_LIMIT) {
        throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);
      }
    }
    const unreadOnly = Boolean(kwargs['unread-only']);

    await page.goto(MESSAGING_URL);
    await page.wait(10);

    // Locate the messaging API request the page fired on load; retry once if the
    // SPA was slow to issue it.
    let located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
    if (located && located.loginRequired) {
      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn requires an active signed-in browser session.');
    }
    if (!located || !located.url) {
      await page.wait(6);
      located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
    }
    if (!located || !located.url) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass an integer value within the allowed MIN_LIMIT..MAX_LIMIT range, e.g. `linkedin inbox --limit 25`.
  2. Check the command help/source for the exact MIN_LIMIT and MAX_LIMIT constants defined in clis/linkedin/inbox.js.
  3. In scripts, coerce and floor the value first (e.g. Math.floor(Number(x))) and skip the flag to use DEFAULT_LIMIT when the value is empty.

Example fix

// before
linkedin inbox --limit 500   // exceeds MAX_LIMIT -> ArgumentError

// after
linkedin inbox --limit 50    // or omit --limit to use DEFAULT_LIMIT
Defensive patterns

Strategy: validation

Validate before calling

const MIN_LIMIT = 1, MAX_LIMIT = 50; // check constants in clis/linkedin/inbox.js
const n = Number(rawLimit);
if (rawLimit !== '' && rawLimit != null && (!Number.isInteger(n) || n < MIN_LIMIT || n > MAX_LIMIT)) {
  throw new RangeError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}`);
}

Type guard

const isValidLimit = (v) => Number.isInteger(Number(v)) && Number(v) >= MIN_LIMIT && Number(v) <= MAX_LIMIT;

Try / catch

try {
  await linkedinInbox({ limit: rawLimit });
} catch (e) {
  if (e instanceof ArgumentError) {
    console.error(`Bad --limit "${rawLimit}"; using default`);
    return linkedinInbox({});
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `linkedin inbox --limit abc` (Number() yields NaN), `--limit 3.5` (not an integer), `--limit 0` or a negative number below MIN_LIMIT, or a value above MAX_LIMIT — all when kwargs.limit is non-empty.

Common situations: Typos or shell quoting issues passing the flag, scripts computing a limit from a float, assuming 0 means 'unlimited' like other tools, or copying a page-size from another CLI whose bounds differ.

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