jackwener/OpenCLI · error · ArgumentError
`endoflife ${label} must be <= ${maxValue}`
Error message
`endoflife ${label} must be <= ${maxValue}` What it means
requireBoundedInt validates a numeric CLI option (e.g. a limit) against a hard upper bound. After confirming the value is a positive integer, it throws ArgumentError when the value exceeds the configured maximum. This guards against nonsensical or abusive inputs that would produce oversized requests to endoflife.date.
Source
Thrown at clis/endoflife/utils.js:37
);
}
if (!PRODUCT.test(s)) {
throw new ArgumentError(
`endoflife product "${value}" is not a valid endoflife.date slug`,
'Slugs are lowercase ASCII letters/digits/"._-", e.g. "nodejs", "python", "ubuntu".',
);
}
return s;
}
export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;
const n = typeof raw === 'number' ? raw : Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(`endoflife ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`endoflife ${label} must be <= ${maxValue}`);
}
return n;
}
export async function eolFetch(url, label) {
let resp;
try {
resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
}
catch (err) {
throw new CommandExecutionError(
`${label} request failed: ${err?.message ?? err}`,
'Check that endoflife.date is reachable from this network.',
);
}
if (resp.status === 404) {
throw new EmptyResultError(label, `endoflife.date returned 404 for ${url}.`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the option value to a positive integer <= the maxValue shown in the message
- Check the CLI help/docs for the documented maximum for that option
- Use the default value by omitting the option entirely
- If you legitimately need more results, paginate by calling the command repeatedly
Example fix
// before $ opencli endoflife cycles nodejs --limit 100 Error: endoflife limit must be <= 20 // after $ opencli endoflife cycles nodejs --limit 20
Defensive patterns
Strategy: validation
Validate before calling
function isBoundedInt(v, max) {
const n = typeof v === 'number' ? v : Number(v);
return Number.isInteger(n) && n > 0 && n <= max ? n : null;
}
const limit = isBoundedInt(opts.limit, 20) ?? 10; // clamp/replace before calling Type guard
const isBoundedPositiveInt = (v, max) => {
const n = typeof v === 'number' ? v : Number(v);
return Number.isInteger(n) && n > 0 && n <= max;
}; Prevention
- Clamp or default the option before passing it to the command
- Consult CLI help for documented maximums of numeric options
- Validate numeric flags at config-load time in scripts
- Avoid hand-editing limit values without checking bounds
When it happens
Trigger: Calling any command whose option flows through requireBoundedInt (e.g. a --limit flag) with an integer greater than the maxValue passed by the adapter, such as limit=50 when maxValue=20.
Common situations: Passing a larger page size than the CLI allows; copy-pasting defaults from another tool; scripting with a variable that was scaled up; assuming there is no cap on the limit option.
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
- --limit must be a positive integer, got ${JSON.stringify(kwa
- facebook search --limit must be an integer between 1 and ${M
- facebook search requires a non-empty query
- ${label} must be a path/URL or a JSON array: ${errorMessage(
- ${name} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/c01ea14cbf9af9aa.
Report an issue: GitHub.