jackwener/OpenCLI · error · ArgumentError
oeis ${label} must be <= ${maxValue}
Error message
oeis ${label} must be <= ${maxValue} What it means
requireBoundedInt enforces an upper bound (maxValue) on numeric options; when the parsed integer exceeds the allowed maximum it throws this ArgumentError naming the label and cap. This keeps requests to the OEIS API within sane/supported sizes. It is thrown after the positive-integer check, so the value is already a valid integer.
Source
Thrown at clis/oeis/utils.js:27
// OEIS ids are A followed by 6 zero-padded digits (older entries use 6 by convention,
// modern entries can be longer; OEIS itself accepts any digits after A).
const SEQUENCE_ID_PATTERN = /^A\d{1,7}$/;
export function requireString(value, label) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError(`oeis ${label} cannot be empty`);
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(`oeis ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`oeis ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireSequenceId(value) {
const raw = String(value ?? '').trim().toUpperCase();
if (!raw) throw new ArgumentError('oeis sequence id is required (e.g. "A000045" for Fibonacci)');
// Tolerate common URL paste like `https://oeis.org/A000045`.
const stripped = raw.replace(/^HTTPS?:\/\/(?:WWW\.)?OEIS\.ORG\//, '').replace(/\/.*$/, '');
if (!SEQUENCE_ID_PATTERN.test(stripped)) {
throw new ArgumentError(
`oeis sequence id "${value}" is not a valid A-number`,
'Expected format: "A" + digits (e.g. "A000045").',
);
}
return stripped;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the value to at most the stated max, e.g. `--limit 100`.
- Read the error message: it includes the exact allowed maximum.
- If you need more data, fetch multiple pages within the bound instead of one oversized request.
Example fix
// before cli --limit 1000 // after cli --limit 100
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(raw);
if (Number.isInteger(n) && n > 100) throw new Error(`--limit must be <= 100, got: ${raw}`); Type guard
function isWithinBound(v, max) { const n = Number(v); return Number.isInteger(n) && n > 0 && n <= max; } Try / catch
try { const limit = requireBoundedInt(opts.limit, 10, 100); } catch (e) { console.error(e.message); process.exitCode = 1; } Prevention
- Clamp user input with Math.min(n, maxValue) before calling.
- Paginate with multiple bounded requests instead of one oversized one.
- Document the cap in your script's help text.
When it happens
Trigger: Calling limit(value, ...) with an integer n where n > maxValue (e.g. limit(500, 10, 100) or `--limit 500` when the cap is 100).
Common situations: Users requesting a very large page size (e.g. `--limit 1000`) assuming the API supports it, or a script iterating with an oversized batch size.
Related errors
- ${label} must be <= ${maxValue}
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search query must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bc828abf37f627fc.
Report an issue: GitHub.