jackwener/OpenCLI · error · ArgumentError
--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got $
Error message
--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed} What it means
parseLimit also enforces the allowed range for --limit: values must be between MIN_LIMIT and MAX_LIMIT (MAX_LIMIT is 40 in the source). It throws ArgumentError when the value is a valid integer but falls outside that range.
Source
Thrown at clis/reuters/utils.js:16
/**
* Shared helpers for the reuters adapter.
*/
import { ArgumentError } from '@jackwener/opencli/errors';
const MIN_LIMIT = 1;
const MAX_LIMIT = 40;
export function parseLimit(raw, fallback = 10) {
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 ${MIN_LIMIT} and ${MAX_LIMIT}, got ${JSON.stringify(raw)}`);
}
if (parsed < MIN_LIMIT || parsed > MAX_LIMIT) {
throw new ArgumentError(`--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed}`);
}
return parsed;
}
/**
* Build the in-page IIFE that fetches the Reuters search API.
*
* Returns a raw envelope `{ ok, status, body, error? }` so that error-handling
* lives in node space (not silently swallowed by `catch(e) {}` inside the
* browser).
*/
export function buildSearchScript(query, count) {
return `
(async () => {
const apiQuery = JSON.stringify({
keyword: ${JSON.stringify(query)},
offset: 0,
orderby: 'display_date:desc',View on GitHub (pinned to 49907e53dc)
Solutions
- Use an integer within the allowed range, e.g. --limit 10 through --limit 40.
- If more results are needed, paginate or run the command multiple times instead of raising --limit.
- Use a positive non-zero value; 0 is below the minimum.
- Check the CLI help for the exact MIN/MAX bounds.
Example fix
// before reuters search "ai" --limit 100 // after reuters search "ai" --limit 40
Defensive patterns
Strategy: validation
Validate before calling
function limitInRange(v, min = 1, max = 40) {
const n = Number(v);
return Number.isInteger(n) && n >= min && n <= max;
}
if (!limitInRange(rawLimit)) rawLimit = 10; // or clamp Type guard
const inRange = (v, min, max) => { const n = Number(v); return Number.isInteger(n) && n >= min && n <= max; }; Try / catch
try {
const limit = parseLimit(rawLimit);
} catch (err) {
if (err instanceof ArgumentError) {
console.warn('limit out of range, clamping to 40');
limit = 40;
} else throw err;
} Prevention
- Clamp values instead of erroring in wrapper scripts.
- Remember the max is 40; paginate for larger result sets.
- Document the bounds in scripts/READMEs that pass --limit.
- Never use 0 as a sentinel for 'unlimited'.
When it happens
Trigger: Invoking the reuters CLI with an integer --limit below MIN_LIMIT (e.g. --limit 0) or above 40 (e.g. --limit 100).
Common situations: Users trying to fetch more results than the CLI caps at (--limit 500), scripts using limit=0 as 'unlimited', or copying page-size conventions from other APIs where 0 or 1000 are valid.
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/7ff588d897ea6642.
Report an issue: GitHub.