jackwener/OpenCLI · error · ArgumentError
${label} must be an integer, got ${JSON.stringify(value)}
Error message
${label} must be an integer, got ${JSON.stringify(value)} What it means
parseIntegerArg coerces an argument to Number and requires a finite integer; non-numeric or fractional values throw ArgumentError(`${label} must be an integer, got ${JSON.stringify(value)}`). It backs the limit and start arguments of the LinkedIn search commands, guaranteeing they are whole numbers before being sent upstream.
Source
Thrown at clis/linkedin/search.js:78
const values = parseCsvArg(input);
const resolved = values.map(value => {
const key = value.toLowerCase();
const mapped = mapping[key];
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;View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a whole number: --limit 25 --start 0.
- Remove thousands separators, units, and percent signs ('10,000' -> 10000).
- Omit the argument entirely to use the fallback default.
- Validate/Number() the value in the calling script before invoking.
Example fix
// before node cli.js linkedin search-jobs --limit 10.5 // ArgumentError: limit must be an integer, got "10.5" // after node cli.js linkedin search-jobs --limit 10
Defensive patterns
Strategy: validation
Validate before calling
function toInt(v, fallback){ if (v === undefined || v === null || v === '') return fallback; const n = Number(String(v).replace(/[,_%\s]/g,'')); if (!Number.isInteger(n)) throw new Error(`--${label} must be an integer`); return n; } Type guard
function isInt(v){ return typeof v === 'number' ? Number.isInteger(v) : Number.isFinite(Number(v)) && Number.isInteger(Number(v)); } Try / catch
try { await search({limit, start}) } catch (e) { if (e instanceof ArgumentError && /must be an integer/.test(e.message)) { console.error(`fix argument: ${e.message}`); process.exitCode = 2; } else throw e; } Prevention
- Strip units, commas, and percent signs from config values before use.
- Coerce config/CLI values with Number() early in your wrapper.
- Omit limit/start to use safe defaults instead of guessing values.
- Add schema validation (e.g. zod integer()) on arguments in wrapper scripts.
When it happens
Trigger: Calling a search command with --limit or --start set to a non-integer string ('twenty', '10.5'), a quoted empty-ish value that isn't caught by the undefined/null/'' check (e.g. spaces or 'null' as text), or an object/array in programmatic use.
Common situations: Shell passing quoted floats or decimals; YAML/JSON config with a string value like '25%'; copying '10,000' with a thousands separator; passing NaN-producing expressions like '1e3.5' or undefined variables rendered as the literal string 'undefined'.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- --city must be a positive integer city ID, got ${JSON.string
- targetCount must be an integer between 1 and 100, got ${JSON
- maxScrolls must be an integer between 1 and 30, got ${JSON.s
- hotel id must be a positive integer, got ${JSON.stringify(ra
- LinkedIn post analytics expected an array of posts
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6f7b56fc0aa7eb31.
Report an issue: GitHub.