jackwener/OpenCLI · warning · ArgumentError
--limit must be between ${HOT_MIN_LIMIT} and ${HOT_MAX_LIMIT
Error message
--limit must be between ${HOT_MIN_LIMIT} and ${HOT_MAX_LIMIT}, got ${parsed} What it means
parseHotLimit validates the `--limit` option of the toutiao hot command. This specific throw fires when the value IS a valid integer but is outside the allowed range [HOT_MIN_LIMIT=1, HOT_MAX_LIMIT=50]. The bound keeps upstream requests valid and prevents over-fetching.
Source
Thrown at clis/toutiao/utils.js:53
}
export function parseRecommendCategory(raw, fallback = '__all__') {
if (raw === undefined || raw === null || raw === '') return fallback;
const value = String(raw).trim();
if (!RECOMMEND_CATEGORIES.includes(value)) {
throw new ArgumentError(`--category must be one of ${RECOMMEND_CATEGORIES.join(', ')}, got ${JSON.stringify(raw)}`);
}
return value;
}
export function parseHotLimit(raw, fallback = 30) {
if (raw === undefined || raw === null || raw === '') return fallback;
const parsed = Number(raw);
if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {
throw new ArgumentError(`--limit must be an integer between ${HOT_MIN_LIMIT} and ${HOT_MAX_LIMIT}, got ${JSON.stringify(raw)}`);
}
if (parsed < HOT_MIN_LIMIT || parsed > HOT_MAX_LIMIT) {
throw new ArgumentError(`--limit must be between ${HOT_MIN_LIMIT} and ${HOT_MAX_LIMIT}, got ${parsed}`);
}
return parsed;
}
const NON_TITLE_LINES = new Set([
'展现', '阅读', '点赞', '评论',
'查看数据', '查看评论', '修改', '更多', '首发',
'已发布', '定时发布', '定时发布中', '由文章生成', '审核中',
]);
const STATS_RE = /展现\s*([\d,]+)\s*阅读\s*([\d,]+)\s*点赞\s*([\d,]+)\s*评论\s*([\d,]*)/;
/**
* Extract creator-backend article rows from the rendered text dump.
*
* Surfaces every row anchored on a `MM-DD HH:MM` line; if the matching stats
* line never came through (slow render / missing element), the row is still
* emitted with `null` for stat columns rather than silently dropped.View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer between 1 and 50 for --limit (default is 30).
- Clamp before invoking: Math.min(50, Math.max(1, n)).
- Omit --limit to use the default of 30.
- For more than 50 items, issue multiple calls or use a different endpoint that supports paging.
Example fix
// before toutiao hot --limit 0 // after toutiao hot --limit 1 # or omit for default 30
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(raw);
if (!Number.isInteger(n) || n < 1 || n > 50) throw new RangeError(`--limit must be an integer between 1 and 50, got ${raw}`); Type guard
const isValidHotLimit = (v) => Number.isInteger(v) && v >= 1 && v <= 50;
Try / catch
try {
parseHotLimit(raw);
} catch (e) {
if (e instanceof ArgumentError) { console.error(e.message); process.exitCode = 2; }
else throw e;
} Prevention
- Clamp computed limits: Math.min(50, Math.max(1, n)).
- Guard loop-derived limits against 0/negative values.
- Omit --limit to use the default of 30.
When it happens
Trigger: Calling toutiao hot with an integer --limit < 1 (e.g. --limit 0) or > 50 (e.g. --limit 500). The Number()/isInteger() checks passed but the range comparison failed.
Common situations: Scripts scaling limit by a factor that lands above 50; loops computing limit from user data yielding 0; copying the limit convention from a different CLI whose max differs.
Related errors
- --limit must be between ${RECOMMEND_MIN_LIMIT} and ${RECOMME
- --category must be one of ${RECOMMEND_CATEGORIES.join(', ')}
- --limit must be an integer between ${HOT_MIN_LIMIT} and ${HO
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/35a7bdc5fb6c7f9d.
Report an issue: GitHub.