jackwener/OpenCLI · warning · ArgumentError

--limit must be a positive integer

Error message

--limit must be a positive integer

What it means

ArgumentError thrown by normalizeJikeLimit when the --limit value (after nullish-coalescing with the default) is not an integer or is less than 1. The library validates user input early so downstream slicing/pagination receives a safe positive integer.

Source

Thrown at clis/jike/utils.js:40

    return { ok: true, user_id: String(u.id), screen_name: String(u.screenName || ''), username: String(u.username || '') };
  } catch (e) {
    return { kind: 'exception', detail: String(e && e.message || e) };
  }
})()`;

export async function requireJikeIdentity(page) {
  const probe = await page.evaluate(JIKE_IDENTITY_PROBE);
  if (probe?.kind === 'auth') throw new AuthRequiredError('web.okjike.com', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jike users/profile`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Jike identity probe failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jike identity probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, screen_name: probe.screen_name, username: probe.username };
}

export function normalizeJikeLimit(raw, defaultValue = 20) {
  const limit = raw ?? defaultValue;
  if (!Number.isInteger(limit) || limit < 1) {
    throw new ArgumentError('--limit must be a positive integer');
  }
  return limit;
}

export async function postJikeApi(page, path, requestBody, label) {
  const url = `https://api.ruguoapp.com${path}`;
  const outcome = await page.evaluate(`(async () => {
    const token = localStorage.getItem('JK_ACCESS_TOKEN') || '';
    const deviceId = localStorage.getItem('JK_DEVICE_ID') || '';
    if (!token) return { kind: 'auth', detail: 'Jike access token is missing' };
    const headers = {
      'content-type': 'application/json',
      'x-jike-access-token': token,
      platform: 'web',
    };
    if (deviceId) headers['x-jike-device-id'] = deviceId;
    try {
      const response = await fetch(${JSON.stringify(url)}, {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a positive integer, e.g. --limit 20
  2. Omit --limit entirely to use the default (20)
  3. Check for shell quoting/variable-expansion issues producing a bad value
  4. Validate the value in any wrapper script before invoking the CLI

Example fix

// before
jike user --limit 0
// after
jike user --limit 20   # or omit --limit for default
Defensive patterns

Strategy: validation

Validate before calling

function isValidLimit(v) { return Number.isInteger(v) && v >= 1; }
if (!isValidLimit(opts.limit)) throw new Error('--limit must be a positive integer');

Type guard

function isPositiveInt(v) { return typeof v === 'number' && Number.isInteger(v) && v >= 1; }

Prevention

When it happens

Trigger: Calling a Jike command with --limit 0, a negative number, a non-numeric string, or a float like 2.5 that reaches the function unconverted.

Common situations: Typing --limit 0 expecting unlimited results; passing a decimal; shell quoting issues passing an empty or malformed string that bypasses the default; scripting the CLI with variables that are unset/invalid.

Related errors


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