jackwener/OpenCLI · error · ArgumentError
--limit must be an integer between 1 and ${max}
Error message
--limit must be an integer between 1 and ${max} What it means
parseLimit converts the --limit argument to a number and throws ArgumentError unless it is an integer between 1 and the given max. Empty/undefined/null falls back to the provided default instead of throwing.
Source
Thrown at clis/linkedin/shared.js:115
throw new ArgumentError(`${label} must be an https LinkedIn URL without credentials or port`);
}
if (host !== 'linkedin.com' && host !== 'www.linkedin.com') {
throw new ArgumentError(`${label} must point to linkedin.com`);
}
return parsed.toString();
}
export function requireStringArg(args, key, label = key) {
const value = normalizeWhitespace(args?.[key]);
if (!value) throw new ArgumentError(`${label} is required`);
return value;
}
export function parseLimit(value, fallback, max) {
if (value === undefined || value === null || value === '') return fallback;
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed < 1 || parsed > max) {
throw new ArgumentError(`--limit must be an integer between 1 and ${max}`);
}
return parsed;
}
export async function requireLinkedInCookie(page, context) {
let cookies;
try {
cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
} catch (error) {
throw new CommandExecutionError(`LinkedIn cookie lookup failed: ${error?.message || error}`);
}
if (!Array.isArray(cookies)) {
throw new CommandExecutionError('LinkedIn cookie lookup returned malformed payload');
}
const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;
if (!jsession) {
throw new AuthRequiredError(LINKEDIN_DOMAIN, `${context} requires an active signed-in LinkedIn browser session.`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use an integer >= 1 and <= the max shown in the message (e.g. --limit 10).
- Omit --limit entirely to use the built-in fallback default.
- Fix non-numeric strings (e.g. 'all') with a plain number.
- Clamp in scripts: `LIMIT=$(( LIMIT < 1 ? 1 : (LIMIT > MAX ? MAX : LIMIT) ))`.
Example fix
// before node cli.js list --limit 0 // after node cli.js list --limit 10 // integer between 1 and max, or omit for default
Defensive patterns
Strategy: validation
Validate before calling
function assertLimit(v, max) {
if (v === undefined || v === null || v === '') return; // default applies
const n = Number(v);
if (!Number.isInteger(n) || n < 1 || n > max) {
throw new Error(`--limit must be an integer between 1 and ${max}`);
}
} Type guard
const isPositiveInt = (v) => Number.isInteger(v) && v >= 1; const limitOk = (v, max) => v === undefined || v === null || v === '' || (isPositiveInt(Number(v)) && Number(v) <= max);
Try / catch
try {
await listCommand({ limit });
} catch (e) {
if (e instanceof ArgumentError && e.message.startsWith('--limit')) {
const max = Number(e.message.match(/between 1 and (\d+)/)?.[1] ?? 50);
console.error(`Invalid --limit; using default. Allowed: 1..${max}`);
} else throw e;
} Prevention
- Omit --limit when you want the default instead of guessing values.
- Remember limits are 1-based integers; 0 is invalid.
- Clamp/round computed limits in scripts before passing them.
- Read the max bound from the error message and respect it.
When it happens
Trigger: Calling a command with e.g. `--limit 0`, `--limit -5`, `--limit 999` (above max), `--limit 3.5` (non-integer), or a non-numeric value like `--limit all`.
Common situations: Users confusing 0-based with 1-based limits, copying a limit from a tool with a higher max, shell scripts interpolating empty/invalid variables into the flag.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- --max-scrolls must be an integer between 0 and 80
- --limit must be an integer between ${MIN_LIMIT} and ${MAX_LI
- job-url must be a https://www.linkedin.com/jobs/view/<id> UR
- --limit must be an integer between 1 and ${MAX_LIMIT}
- --recipient must be a Sales Navigator lead URL, Sales Naviga
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b1e5257f932991a6.
Report an issue: GitHub.