jackwener/OpenCLI · error · ArgumentError
tvmaze ${label} must be <= ${maxValue}
Error message
tvmaze ${label} must be <= ${maxValue} What it means
requireBoundedInt enforces an upper bound (maxValue) on numeric options and throws ArgumentError when the value exceeds it. TVmaze caps page sizes/results per request, so limits above the API maximum are rejected before a request is wasted. This error means the value was a valid positive integer but larger than maxValue.
Source
Thrown at clis/tvmaze/utils.js:35
const raw = value;
const n = typeof raw === 'number' ? raw : Number(String(raw ?? '').trim());
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(
'tvmaze show id is required and must be a positive integer',
'TVmaze show ids appear in the URL: https://www.tvmaze.com/shows/<id>/<slug>.',
);
}
return n;
}
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(`tvmaze ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`tvmaze ${label} must be <= ${maxValue}`);
}
return n;
}
export async function tvmazeFetch(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 api.tvmaze.com is reachable from this network.',
);
}
if (resp.status === 404) {
throw new EmptyResultError(label, `TVmaze returned 404 for ${url}.`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the limit to <= the stated maximum (the message shows the exact maxValue)
- If you need more items, page through results with repeated calls instead of one oversized request
- Check the command's help text for the accepted range
Example fix
// before cli --limit 500 // after cli --limit 250 // or the maxValue printed in the error
Defensive patterns
Strategy: validation
Validate before calling
function clampLimit(value, max) {
const n = Number(value);
if (!Number.isInteger(n) || n <= 0) return undefined; // let default apply
return Math.min(n, max);
}
// e.g. const limit = clampLimit(userLimit, 250); Type guard
function isWithinBounds(v, max) {
const n = Number(v);
return Number.isInteger(n) && n > 0 && n <= max;
} Try / catch
try {
await cli(['tvmaze', 'list', '--limit', String(limit)]);
} catch (err) {
if (err.name === 'ArgumentError' && /must be <= /.test(err.message)) {
const max = Number(err.message.match(/<= (\d+)/)?.[1]);
console.error(`--limit too high; max is ${max}.`);
} else throw err;
} Prevention
- Check the command's help/README for the maximum limit per endpoint
- Clamp user input with Math.min(n, max) instead of passing it raw
- Page through results for large datasets rather than raising the limit
When it happens
Trigger: Calling a tvmaze command with --limit above the endpoint's maximum (e.g. limit 100 when maxValue is 20 or 250 depending on the command).
Common situations: Reusing a limit tuned for another API, assuming 'bigger is fine', or misreading the endpoint's documented max results per page.
Related errors
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- dblp ${label} must be a positive integer
- dblp ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fd934df61c7951f4.
Report an issue: GitHub.