jackwener/OpenCLI · error · ArgumentError
juejin ${label} must be <= ${maxValue}
Error message
juejin ${label} must be <= ${maxValue} What it means
requireBoundedInt enforces an upper bound (maxValue) on limit-like arguments. When the parsed positive integer exceeds the command's configured maximum, this ArgumentError is thrown with the exact allowed maximum in the message, preventing oversized requests that the API would reject or that would waste resources.
Source
Thrown at clis/juejin/utils.js:50
}
export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;
let n;
if (typeof raw === 'number') {
n = raw;
}
else if (typeof raw === 'string' && /^[1-9]\d*$/.test(raw)) {
n = Number(raw);
}
else {
throw new ArgumentError(`juejin ${label} must be a positive decimal integer`);
}
if (!Number.isSafeInteger(n) || n <= 0) {
throw new ArgumentError(`juejin ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`juejin ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireCursor(value) {
const raw = value ?? '0';
if (typeof raw === 'number') {
if (Number.isSafeInteger(raw) && raw >= 0) return String(raw);
throw new ArgumentError('juejin cursor must be a non-negative decimal integer');
}
if (typeof raw === 'string' && /^(0|[1-9]\d*)$/.test(raw)) {
return raw;
}
throw new ArgumentError('juejin cursor must be a non-negative decimal integer');
}
/** Resolve a `--category` arg to the underlying numeric category id. */
export function resolveCategory(value) {View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the limit to the value named in the error message (e.g. --limit 50).
- To fetch more items, paginate: loop with --limit <max> and follow next_cursor instead of one huge request.
- Clamp in your wrapper script: n = Math.min(maxAllowed, requested).
- Check the command's --help for its documented maximum.
Example fix
// before
cli({ limit: 1000 }); // exceeds max
// after
for (let cursor = '0'; cursor !== ''; ) {
const page = cli({ limit: 50, cursor });
cursor = page.next_cursor;
} Defensive patterns
Strategy: validation
Validate before calling
const MAX = 50; // match the command's documented max
function safeLimit(n){ return Math.min(MAX, Math.max(1, Math.floor(Number(n) || 1))); }
// cli({ limit: safeLimit(requested) }) Type guard
function isWithinMax(v, max){ return typeof v === 'number' && Number.isSafeInteger(v) && v > 0 && v <= max; } Try / catch
try {
cli({ limit });
} catch (e) {
const m = /must be <= (\d+)/.exec(e.message);
if (m) cli({ limit: Number(m[1]) }); // retry at the exact allowed max
else throw e;
} Prevention
- Read --help for each command's maximum; maxima differ per endpoint.
- Paginate with next_cursor instead of raising the limit beyond the cap.
- Centralize the max in one constant shared by all your wrappers.
When it happens
Trigger: Passing a limit above the command's max, e.g. --limit 1000 where the recommend command's maxValue is 50, or --limit 100 on an endpoint capped at 20.
Common situations: Reusing a limit tuned for a different CLI/API with a higher cap; config files shared across commands with different maxima; scripting pagination with pagesize set larger than the server allows.
Related errors
- --page must be a positive integer (got ${raw})
- --${name} must be between ${min} and ${max}, got ${parsed}
- --offset must be a multiple of 10 for DuckDuckGo HTML pagina
- INVALID_LIMIT
- --limit must be an integer between 1 and 500
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/438964fbf79b49b3.
Report an issue: GitHub.