jackwener/OpenCLI · error · ArgumentError
${label} must be ${range}, got ${parsed}
Error message
${label} must be ${range}, got ${parsed} What it means
After confirming the value is an integer, parseIntegerArg range-checks it against [min, max]; out-of-range values throw ArgumentError(`${label} must be ${range}, got ${parsed}`). The range text says 'between min and max' when max is finite, or 'at least min' when max is Infinity, so limit/start arguments stay within what the LinkedIn search API and CLI accept.
Source
Thrown at clis/linkedin/search.js:82
if (!mapped)
throw new ArgumentError(`Unsupported ${label}: ${value}`);
return mapped;
});
return [...new Set(resolved)];
}
function normalizeWhitespace(value) {
return String(value ?? '').replace(/\s+/g, ' ').trim();
}
function parseIntegerArg(value, label, fallback, min, max = Infinity) {
if (value === undefined || value === null || value === '')
return fallback;
const parsed = Number(value);
if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {
throw new ArgumentError(`${label} must be an integer, got ${JSON.stringify(value)}`);
}
if (parsed < min || parsed > max) {
const range = Number.isFinite(max) ? `between ${min} and ${max}` : `at least ${min}`;
throw new ArgumentError(`${label} must be ${range}, got ${parsed}`);
}
return parsed;
}
function decodeLinkedinRedirect(url) {
if (!url)
return '';
try {
const parsed = new URL(url);
if (parsed.pathname === '/redir/redirect/') {
return parsed.searchParams.get('url') || url;
}
}
catch { }
return url;
}
function buildVoyagerSearchQuery(input) {
const hasFilters = input.companyIds.length ||
input.experienceLevels.length ||View on GitHub (pinned to 49907e53dc)
Solutions
- Clamp limit/start into the documented range for that command (check its --help for min/max).
- Use the argument's default by omitting it, and paginate by advancing start instead of raising limit.
- Fix negative offsets by flooring start at 0.
- Handle range errors programmatically by parsing the min/max out of the message before retrying.
Example fix
// before node cli.js linkedin search-people --limit 1000 # above max // ArgumentError: limit must be between 1 and 100, got 1000 // after node cli.js linkedin search-people --limit 100 --start 0 node cli.js linkedin search-people --limit 100 --start 100 # paginate instead
Defensive patterns
Strategy: validation
Validate before calling
limit = Math.max(minLimit, Math.min(maxLimit, Number(limit) || defaultLimit)); start = Math.max(0, Number(start) || 0);
Type guard
function inRange(n, min, max = Infinity){ return Number.isInteger(n) && n >= min && n <= max; } Try / catch
try { await search({limit, start}) } catch (e) { const m = /must be (?:between (\d+) and (\d+)|at least (\d+))/.exec(e.message); if (m) { /* clamp and retry once */ } else throw e; } Prevention
- Clamp limit/start to the documented min/max before every call.
- Paginate by advancing start rather than inflating limit.
- Floor negative offsets at 0.
- Re-check ranges after CLI upgrades that may change limits.
When it happens
Trigger: Calling a search command with --limit or --start below its minimum (e.g. 0 or negative) or above its maximum (e.g. --limit 500 where the max is smaller), or --start negative for pagination offset.
Common situations: 'Fetch everything' scripts that set an oversized limit; off-by-one pagination producing start=-1; hardcoding limit=0 expecting 'no cap' instead of the documented default; raising limits after a CLI version lowered the max.
Related errors
- limit must be a positive integer (1-${max})
- limit must be <= ${max}
- limit must be <= 250 (CoinGecko per_page upper bound)
- limit must be an integer between 1 and ${max}
- douyin videos limit must be an integer between ${MIN_LIMIT}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/82887d0cb1c57974.
Report an issue: GitHub.