jackwener/OpenCLI · error · CommandExecutionError
Qianwen history page_size must be an integer between 1 and 1
Error message
Qianwen history page_size must be an integer between 1 and 100
What it means
getSessionListFromApi in clis/qwen/utils.js coerces limit via Number(limit ?? 30) and throws CommandExecutionError('Qianwen history page_size must be an integer between 1 and 100') when the value is not an integer, <= 0, or > 100. The value is sent as page_size to the Qianwen history API, which enforces a 1-100 range server-side.
Source
Thrown at clis/qwen/utils.js:414
const waitFor = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const label = ${JSON.stringify(label)};
const button = Array.from(document.querySelectorAll('button[aria-label]'))
.find((node) => isVisible(node) && node.getAttribute('aria-label') === label);
if (!(button instanceof HTMLElement)) return { found: false };
const selected = button.getAttribute('aria-pressed') === 'true'
|| /active|selected|bg-primary/.test(button.className || '');
if (selected === ${Boolean(enabled)}) return { found: true, changed: false, selected };
button.click();
await waitFor(300);
return { found: true, changed: true };
})()`);
return Boolean(result?.found);
}
export async function getSessionListFromApi(page, limit = 30) {
const pageSize = Number(limit ?? 30);
if (!Number.isInteger(pageSize) || pageSize <= 0 || pageSize > 100) {
throw new CommandExecutionError('Qianwen history page_size must be an integer between 1 and 100');
}
const result = await page.evaluate(`(async () => {
try {
const utdid = (document.cookie.match(/(?:^|;\\s*)b-user-id=([^;]+)/)?.[1])
|| (document.cookie.match(/(?:^|;\\s*)utdid=([^;]+)/)?.[1])
|| '';
const query = new URLSearchParams({
biz_id: 'ai_qwen',
chat_client: 'h5',
device: 'pc',
fr: 'pc',
pr: 'qwen',
ut: utdid,
la: 'zh-CN',
tz: 'Asia/Shanghai',
ve: '2.4.9',
}).toString();
const res = await fetch('https://${QIANWEN_API_DOMAIN}/api/v2/session/page/list?' + query, {View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer between 1 and 100, e.g. limit = 100 (the maximum)
- Fetch all pages by looping with page_size=100 and paging until fewer than 100 results return
- Coerce/validate the value in your script before calling (Number.isInteger and 1-100 range)
- Remove unit suffixes or invalid strings from the limit config entry
Example fix
// before
const sessions = await getSessionListFromApi(page, 500);
// after
let sessions = [];
for (let offset = 0; ; offset += 100) {
const page_ = await getSessionListFromApi(page, 100);
sessions = sessions.concat(page_);
if (page_.length < 100) break;
} Defensive patterns
Strategy: validation
Validate before calling
function assertPageSize(limit) {
const n = Number(limit ?? 30);
if (!Number.isInteger(n) || n <= 0 || n > 100) {
throw new Error(`page_size must be an integer 1-100, got: ${JSON.stringify(limit)}`);
}
return n;
}
assertPageSize(userLimit); Type guard
const isValidPageSize = (v) => {
const n = Number(v);
return Number.isInteger(n) && n >= 1 && n <= 100;
}; Try / catch
try {
const sessions = await getSessionListFromApi(page, limit);
} catch (e) {
if (/page_size must be an integer between 1 and 100/.test(e.message)) {
console.warn('Clamping page_size to 100 and retrying');
return getSessionListFromApi(page, Math.min(100, Math.max(1, Number(limit) || 30)));
} else throw e;
} Prevention
- Cap page_size at 100 — that is the API maximum
- Paginate (loop with page_size=100) instead of requesting one huge page
- Sanitize config values: reject empty strings and non-numeric entries before calling
- Reuse one validated clamp helper wherever limit/page_size is passed
When it happens
Trigger: Calling with limit > 100 (e.g. 500 to 'get everything'); passing a non-integer (2.5, 'all', ''); limit resolving to 0 or negative from an empty/invalid variable; NaN from a non-numeric string.
Common situations: Wanting the full history and guessing a huge page_size; config files with limit: '' or null-like strings; API changes tightening the server cap; scripts multiplying values (30 * 10 = 300 -> rejected).
Related errors
- limit must be <= 250 (CoinGecko per_page upper bound)
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- Bilibili view API did not return pages[] for --page selectio
- 分P 序号超出范围:p=${pageNum}(该视频共 ${total} 集)
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a5009cb1428068fb.
Report an issue: GitHub.