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
parseLimit throws ArgumentError when the value is a finite integer but outside the 1-100 window accepted by rednote search (0, negatives, or >100). The message embeds the coerced number. Search results are capped at 100 by design.
Source
Thrown at clis/rednote/search.js:19
/**
* Rednote search — international mirror of xiaohongshu/search.
*
* Reuses the DOM-extraction IIFE from `../xiaohongshu/search.js`; only the
* web host and the login-gate detection differ. See issue #1136 for the
* 1:1 comparison between the two frontends.
*/
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { buildScrollUntilJs, buildSearchExtractJs, noteIdToDate } from '../xiaohongshu/search.js';
import { unwrapEvaluateResult } from '../xiaohongshu/shared.js';
function parseLimit(raw) {
const parsed = Number(raw);
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;
}
function requireSearchRows(payload) {
const rows = unwrapEvaluateResult(payload);
if (!Array.isArray(rows)) {
throw new CommandExecutionError('Unexpected Rednote search extraction payload shape; expected an array of rows.');
}
return rows;
}
/**
* Wait for search results or login wall using MutationObserver (max 5s).
*
* Differs from xiaohongshu by detecting a full-screen login modal instead
* of (and as a fallback, alongside) the inline `登录后查看搜索结果` text.
* The modal detector filters hidden / zero-area elements to avoid false
* positives on background dialogs.View on GitHub (pinned to 49907e53dc)
Solutions
- Use --limit within 1-100; clamp with Math.min(100, Math.max(1, n))
- If more results are needed, paginate using different queries/keywords rather than raising the cap
- Adjust batch scripts to slice requests into <=100 chunks
Example fix
// before const limit = totalWanted; // e.g. 500 // after const limit = Math.min(100, Math.max(1, totalWanted)); // paginate for the rest
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(raw); if (Number.isInteger(n) && (n < 1 || n > 100)) throw new Error(`--limit must be between 1 and 100, got ${n}`); Type guard
const inSearchRange = (v) => { const n = Number(v); return Number.isInteger(n) && n >= 1 && n <= 100; }; Try / catch
try { await runSearch({ query, limit }); } catch (e) { if (e instanceof ArgumentError && /between 1 and 100/.test(e.message)) { return runSearch({ query, limit: Math.min(100, Math.max(1, limit)) }); } throw e; } Prevention
- Clamp with Math.min(100, Math.max(1, n)) in wrappers
- Split bulk requests into pages of at most 100
- Do not copy unbounded-limit assumptions from other rednote subcommands
When it happens
Trigger: Passing --limit 0, --limit 101, or any negative integer to the rednote search command.
Common situations: Users wanting 'everything' passing a huge number like 1000, batch scripts computing page sizes that exceed the cap, or porting code from other rednote commands (notifications/user) whose limits are unbounded above.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
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/f6f18dbc070077af.
Report an issue: GitHub.