{"record":{"id":"0572bc310d523902","repo":"jackwener/OpenCLI","slug":"limit-must-be-100-0572bc","errorCode":null,"errorMessage":"limit must be <= 100","messagePattern":"limit must be <= 100","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/qwen/history.js","lineNumber":39,"sourceCode":"    name: 'history',\n    access: 'read',\n    description: 'List recent Qianwen conversations (requires login)',\n    domain: QIANWEN_DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    siteSession: 'persistent',\n    navigateBefore: false,\n    args: [\n        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },\n    ],\n    columns: ['Index', 'Title', 'Updated', 'Url'],\n    func: async (page, kwargs) => {\n        const limit = Number(kwargs.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('limit must be a positive integer');\n        }\n        if (limit > 100) {\n            throw new ArgumentError('limit must be <= 100');\n        }\n        await ensureOnQianwen(page);\n        await dismissLoginModal(page);\n        await page.wait(1);\n        const result = await getSessionListFromApi(page, limit);\n        if (!result.ok) {\n            if (result.status === 401 || result.status === 403) throw authRequired();\n            if (!result.sessions.length) {\n                throw new CommandExecutionError(`Qianwen history API failed (status=${result.status}) ${result.error || ''}`.trim());\n            }\n        }\n        if (!result.sessions.length) {\n            throw new EmptyResultError('qwen history', 'No Qianwen conversations found.');\n        }\n        return result.sessions.slice(0, limit).map((s, i) => ({\n            Index: i + 1,\n            Title: s.title || '(untitled)',\n            Updated: formatDate(s.updated_at),","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/history.js#L21-L57","documentation":"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.","triggerScenarios":"Calling `qwen history --limit 101` (or any larger number, or a programmatic call with limit > 100) through the history command's func.","commonSituations":"Users assuming 'limit' is unlimited and passing 500/1000; automation deriving limit from a page-size constant larger than the API's cap.","solutions":["Cap the value at 100: use --limit 100.","Clamp in code before calling: limit = Math.min(Number(limit), 100).","If you need more than 100 conversations, paginate by calling the command repeatedly with different offsets if supported.","Keep the default 20 unless you specifically need up to 100."],"exampleFix":"// before\nqwen history --limit 500\n// after\nqwen history --limit 100","handlingStrategy":"validation","validationCode":"const n = Number(rawLimit);\nconst limit = Math.min(Math.max(Number.isInteger(n) ? n : 20, 1), 100);","typeGuard":"function isValidLimit(v) {\n  return Number.isInteger(v) && v > 0 && v <= 100;\n}","tryCatchPattern":"try {\n  const rows = await qwenHistory({ limit });\n} catch (e) {\n  if (/limit must be <= 100/.test(e.message)) {\n    const rows = await qwenHistory({ limit: 100 });\n  } else throw e;\n}","preventionTips":["Clamp user-supplied limits with Math.min(n, 100) before calling.","Remember the hard cap is 100 per call; paginate instead of raising the limit.","Document the 1–100 range wherever the CLI is wrapped by scripts/UIs.","Prefer the default 20 unless more rows are genuinely needed."],"tags":["validation","argument-error","cli","limits"],"backgroundTag":"parameter-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}