jackwener/OpenCLI · warning · ArgumentError
weibo favorites ${name} must be <= ${MAX_LIMIT}
Error message
weibo favorites ${name} must be <= ${MAX_LIMIT} What it means
clis/weibo/favorites.js:15 — parsePositiveInt throws ArgumentError(`weibo favorites ${name} must be <= ${MAX_LIMIT}`) when a valid positive integer option exceeds MAX_LIMIT (50). The cap exists because the scraper reads the visible favorites page; requesting more than 50 cannot be satisfied reliably.
Source
Thrown at clis/weibo/favorites.js:15
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { getSelfUid, requireArrayEvaluateResult, unwrapEvaluateResult } from './utils.js';
const DEFAULT_LIMIT = 20;
const MAX_LIMIT = 50;
function parsePositiveInt(value, name, defaultValue) {
const raw = value ?? defaultValue;
const number = Number(raw);
if (!Number.isInteger(number) || number <= 0) {
throw new ArgumentError(`weibo favorites ${name} must be a positive integer`);
}
if (number > MAX_LIMIT) {
throw new ArgumentError(`weibo favorites ${name} must be <= ${MAX_LIMIT}`);
}
return number;
}
function parseFavoriteCard(card, favUrl) {
const raw = String(card?.text ?? '');
const lines = raw.split('\n');
let author = '';
let time = '';
let source = '';
let content = '';
let likes = '0';
let comments = '0';
let reposts = '0';
for (const line of lines) {
const t = line.trim();View on GitHub (pinned to 49907e53dc)
Solutions
- Cap the request at 50: use limit: 50 and paginate/aggregate multiple calls if you need more
- Clamp in your own code before calling: Math.min(desiredLimit, 50)
- For bulk exports, loop with limit=50 and deduplicate results between pages
- Do not set limit to an enormous number hoping the CLI clamps — it throws instead
Example fix
// before
await cli.run('weibo favorites', { limit: 200 }); // ArgumentError
// after
const limit = Math.min(Math.max(1, Number(cfg.limit) || 20), 50);
await cli.run('weibo favorites', { limit }); Defensive patterns
Strategy: validation
Validate before calling
const MAX_LIMIT = 50;
function clampLimit(v, fallback = 20) {
const n = v == null || v === '' ? fallback : Number(v);
if (!Number.isInteger(n) || n <= 0) return fallback;
return Math.min(n, MAX_LIMIT);
} Type guard
function isWithinLimit(v, max = 50) { return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= max; } Try / catch
try {
await cli.run('weibo favorites', { limit });
} catch (e) {
if (e instanceof Error && /must be <= 50/.test(e.message)) {
console.error('Cap favorites limit at 50; paginate for more.');
}
throw e;
} Prevention
- Clamp with Math.min(desired, 50) before every call
- Paginate with repeated limit=50 calls for bulk retrieval
- Document the 50 cap in any wrapper you build around the CLI
- Never pass 'all'-style sentinel values like 9999
When it happens
Trigger: Calling `weibo favorites` with limit=100, 500, or any integer > 50; scripts passing a page-size constant that exceeds the CLI's cap.
Common situations: Users assuming the API paginates arbitrarily like official Weibo APIs; reusing a limit from another tool with a higher cap; batch export scripts requesting 'all' favorites via a huge number.
Related errors
- weibo favorites ${name} must be a positive integer
- archive search limit must be <= 100
- coingecko derivatives limit must be <= 500
- limit must be an integer between 1 and 15 (dianping single p
- limit must be an integer between 1 and ${max}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e9909fc7cb48810c.
Report an issue: GitHub.