jackwener/OpenCLI · error · ArgumentError
--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got $
Error message
--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed} What it means
parseListLimit throws this when the value is an integer but falls outside the configured MIN_LIMIT/MAX_LIMIT bounds. It's a range check after the integer check, so the value parses fine but is simply too small or too large for list queries.
Source
Thrown at clis/trip/utils.js:58
if (month < 1 || month > 12 || day < 1 || day > 31) {
throw new ArgumentError(`--${name} has invalid month/day: ${value}`);
}
// Cross-check via UTC date math so 2026-02-30 doesn't pass.
const parsed = new Date(Date.UTC(year, month - 1, day));
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) {
throw new ArgumentError(`--${name} is not a real calendar date: ${value}`);
}
return value;
}
export function parseListLimit(raw, fallback = 20) {
if (raw === undefined || raw === null || raw === '') return fallback;
const parsed = Number(raw);
if (!Number.isFinite(parsed) || !Number.isInteger(parsed)) {
throw new ArgumentError(`--limit must be an integer between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${JSON.stringify(raw)}`);
}
if (parsed < MIN_LIMIT || parsed > MAX_LIMIT) {
throw new ArgumentError(`--limit must be between ${MIN_LIMIT} and ${MAX_LIMIT}, got ${parsed}`);
}
return parsed;
}
export function buildFlightSearchUrl(fromCode, toCode, date) {
const params = new URLSearchParams({
dcity: fromCode.toLowerCase(),
acity: toCode.toLowerCase(),
ddate: date,
triptype: 'ow',
class: 'y',
quantity: '1',
locale: 'en_US',
curr: 'USD',
});
return `https://www.trip.com/flights/showfarefirst?${params.toString()}`;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Set --limit within the documented bounds shown in the error message
- If you want everything, use the maximum allowed value for --limit instead of 0 or a huge number
- Paginate with repeated calls if you need more results than MAX_LIMIT
- Check the CLI help or source constants for the exact MIN/MAX values
Example fix
// before clis-trip hotels --city-id 338 --checkin 2026-10-01 --checkout 2026-10-05 --limit 0 // after clis-trip hotels --city-id 338 --checkin 2026-10-01 --checkout 2026-10-05 --limit 20
Defensive patterns
Strategy: validation
Validate before calling
const n = Number(limit);
if (limit !== undefined && Number.isInteger(n) && (n < MIN || n > MAX)) {
throw new Error(`--limit must be between ${MIN} and ${MAX}, got ${n}`);
} Type guard
function isLimitInRange(v, min, max) {
const n = Number(v);
return Number.isInteger(n) && n >= min && n <= max;
} Try / catch
try {
runTripCli(['hotels', '--limit', limit]);
} catch (err) {
if (err instanceof ArgumentError && /--limit must be between/.test(err.message)) {
console.error(`--limit out of range: ${err.message}. Clamp or paginate instead.`);
process.exitCode = 2;
} else throw err;
} Prevention
- Clamp limit values to the documented MIN/MAX before invoking
- Never use 0 or negatives to mean 'unlimited' — use the max value
- Paginate with repeated calls if results exceed MAX_LIMIT
- Keep page-size configs per-service, not shared globally
When it happens
Trigger: Calling limit with --limit 0, --limit -5, or an extremely large value such as --limit 100000 that exceeds MAX_LIMIT (the bounds come from the MIN_LIMIT/MAX_LIMIT constants).
Common situations: Passing 0 or a negative to mean 'unlimited'; assuming pagination size limits of other tools apply here; config files with page-size values from a different service.
Related errors
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
- --from and --to must differ; both resolved to ${fromStation.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/84b158847b599cfe.
Report an issue: GitHub.