jackwener/OpenCLI · error · ArgumentError
--limit must be an integer between 1 and 500
Error message
--limit must be an integer between 1 and 500
What it means
parseLimit validates the --limit argument: it must be an integer from 1 to 500 (default 25 when omitted). Non-numeric strings, floats, or out-of-range values throw ArgumentError.
Source
Thrown at clis/linkedin/salesnav-search.js:28
// /sales/search/people request.
const LEAD_SEARCH_DECORATION = 'com.linkedin.sales.deco.desktop.searchv2.LeadSearchResult-14';
const PAGE_SIZE = 25;
function normalizeWhitespace(value) {
return String(value ?? '').replace(/[ ]/g, ' ').replace(/\s+/g, ' ').trim();
}
function requireStringArg(args, key, label = key) {
const value = normalizeWhitespace(args[key]);
if (!value) throw new ArgumentError(`${label} is required`);
return value;
}
function parseLimit(value) {
if (value === undefined || value === null || value === '') return 25;
const limit = Number(value);
if (!Number.isInteger(limit) || limit < 1 || limit > 500) {
throw new ArgumentError('--limit must be an integer between 1 and 500');
}
return limit;
}
// Sales Navigator keeps the structural ( ) , : of the query literal and only
// percent-encodes the keyword value.
function leadSearchUrl(keywords, start) {
const query = '(spellCorrectionEnabled:true,recentSearchParam:(doLogHistory:true),keywords:'
+ encodeURIComponent(keywords) + ')';
return LEAD_SEARCH_BASE
+ '?q=searchQuery&query=' + query
+ '&start=' + start + '&count=' + PAGE_SIZE
+ '&decorationId=' + LEAD_SEARCH_DECORATION;
}
function fetchLeadSearchScript(url, csrf) {
return String.raw`(async () => {
const headers = {View on GitHub (pinned to 49907e53dc)
Solutions
- Use an integer in [1, 500], e.g. --limit 100.
- Omit --limit entirely to use the default of 25.
- Clamp or validate the value in your wrapper script before invoking the CLI.
Example fix
// before --limit 1000 // after --limit 500
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(rawLimit);
if (!Number.isInteger(n) || n < 1 || n > 500) throw new Error('--limit must be an integer between 1 and 500'); Type guard
function isValidLimit(v) {
const n = Number(v);
return Number.isInteger(n) && n >= 1 && n <= 500;
} Prevention
- Clamp user-supplied limits to 1..500 before invoking
- Omit the flag to accept the default of 25
- Sanitize locale-formatted numbers (strip commas) first
- Document the 500 cap in tooling that surfaces this CLI
When it happens
Trigger: Passing --limit 0, --limit 501, --limit abc, --limit 25.5, or any value Number() cannot turn into an integer.
Common situations: Users assuming a larger page size is allowed (Sales Navigator caps at 500); copying a limit from another CLI with different bounds; locale-formatted numbers like '1,000'.
Related errors
- --${name} must be between ${min} and ${max}, got ${parsed}
- ${label} must be between ${min} and ${max}, got ${parsed}
- ${label} must be <= ${max}
- 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/0fa2af8cae15a496.
Report an issue: GitHub.