jackwener/OpenCLI · error · ArgumentError

limit must be <= 100

Error message

limit must be <= 100

What it means

After the positive-integer check, `qwen history` enforces an upper bound: limit > 100 throws ArgumentError('limit must be <= 100') at clis/qwen/history.js:39. The Qianwen session-list API is only queried for at most 100 conversations per call, so larger values are rejected up front.

Source

Thrown at clis/qwen/history.js:39

    name: 'history',
    access: 'read',
    description: 'List recent Qianwen conversations (requires login)',
    domain: QIANWEN_DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },
    ],
    columns: ['Index', 'Title', 'Updated', 'Url'],
    func: async (page, kwargs) => {
        const limit = Number(kwargs.limit ?? 20);
        if (!Number.isInteger(limit) || limit <= 0) {
            throw new ArgumentError('limit must be a positive integer');
        }
        if (limit > 100) {
            throw new ArgumentError('limit must be <= 100');
        }
        await ensureOnQianwen(page);
        await dismissLoginModal(page);
        await page.wait(1);
        const result = await getSessionListFromApi(page, limit);
        if (!result.ok) {
            if (result.status === 401 || result.status === 403) throw authRequired();
            if (!result.sessions.length) {
                throw new CommandExecutionError(`Qianwen history API failed (status=${result.status}) ${result.error || ''}`.trim());
            }
        }
        if (!result.sessions.length) {
            throw new EmptyResultError('qwen history', 'No Qianwen conversations found.');
        }
        return result.sessions.slice(0, limit).map((s, i) => ({
            Index: i + 1,
            Title: s.title || '(untitled)',
            Updated: formatDate(s.updated_at),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Cap the value at 100: use --limit 100.
  2. Clamp in code before calling: limit = Math.min(Number(limit), 100).
  3. If you need more than 100 conversations, paginate by calling the command repeatedly with different offsets if supported.
  4. Keep the default 20 unless you specifically need up to 100.

Example fix

// before
qwen history --limit 500
// after
qwen history --limit 100
Defensive patterns

Strategy: validation

Validate before calling

const n = Number(rawLimit);
const limit = Math.min(Math.max(Number.isInteger(n) ? n : 20, 1), 100);

Type guard

function isValidLimit(v) {
  return Number.isInteger(v) && v > 0 && v <= 100;
}

Try / catch

try {
  const rows = await qwenHistory({ limit });
} catch (e) {
  if (/limit must be <= 100/.test(e.message)) {
    const rows = await qwenHistory({ limit: 100 });
  } else throw e;
}

Prevention

When it happens

Trigger: Calling `qwen history --limit 101` (or any larger number, or a programmatic call with limit > 100) through the history command's func.

Common situations: Users assuming 'limit' is unlimited and passing 500/1000; automation deriving limit from a page-size constant larger than the API's cap.

Related errors


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