jackwener/OpenCLI · error · ArgumentError
--limit must be between 1 and 100, got ${parsed}
Error message
--limit must be between 1 and 100, got ${parsed} What it means
After parseLimit confirms the --limit value is a finite integer, it enforces the supported range of 1–100. Integers outside that range throw this ArgumentError including the parsed value. The range cap typically mirrors the upstream site/page-size limit.
Source
Thrown at clis/smzdm/search.js:44
function parseLimit(raw) {
let parsed;
if (raw == null) {
parsed = 20;
}
else if (typeof raw === 'number') {
parsed = raw;
}
else if (typeof raw === 'string' && /^[0-9]+$/.test(raw)) {
parsed = Number(raw);
}
else {
parsed = NaN;
}
if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {
throw new ArgumentError(`--limit must be an integer between 1 and 100, got ${JSON.stringify(raw)}`);
}
if (parsed < 1 || parsed > 100) {
throw new ArgumentError(`--limit must be between 1 and 100, got ${parsed}`);
}
return parsed;
}
/**
* Build the in-page extraction script. Every result row carries the full
* declared column set; interaction metrics default to 0 and the update time
* to '' when a list item omits them, so no column is ever silently dropped.
*/
function buildSmzdmSearchJs(limit) {
return `
(() => {
const limit = ${limit};
const items = document.querySelectorAll('li.feed-row-wide');
const results = [];
const normalizeCount = (text) => {
const raw = (text || '').replace(/,/g, '').trim();
const match = raw.match(/(\\d+(?:\\.\\d+)?)\\s*([万kK]?)/);View on GitHub (pinned to 49907e53dc)
Solutions
- Use a limit between 1 and 100: --limit 100 is the maximum.
- If more results are needed, paginate with multiple searches instead of one large limit.
- Clamp the value in wrapper scripts: Math.min(100, Math.max(1, n)).
Example fix
// before opencli smzdm search headphones --limit 500 // after opencli smzdm search headphones --limit 100
Defensive patterns
Strategy: validation
Validate before calling
const clamped = Math.min(100, Math.max(1, Math.round(Number(raw))));
if (!Number.isInteger(clamped)) throw new Error('limit must resolve to an integer'); Try / catch
try {
await run(['smzdm', 'search', q, '--limit', String(limit)]);
} catch (e) {
if (e.message.includes('--limit must be between 1 and 100')) { limit = 100; /* retry clamped */ }
else throw e;
} Prevention
- Clamp limits at the call site with Math.min/Math.max before invoking.
- Remember 100 is the maximum; paginate for more results.
- Guard computed limits against 0/negative results from page math.
When it happens
Trigger: Passing --limit 0, --limit -5, or --limit 101+ to the smzdm search command with a value that is a valid integer but out of bounds.
Common situations: Users wanting 'everything' guess a huge limit like 1000; computed limits from page math produce 0; copy-pasted configs use 500.
Related errors
- ${label} must be between ${min} and ${max}, got ${parsed}
- ${label} must be <= ${max}
- --${name} must be between ${min} and ${max}, got ${parsed}
- flomo memos --${name} must be between 1 and ${max}
- limit must be an integer between 1 and ${max}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7429f352e2d920fc.
Report an issue: GitHub.