jackwener/OpenCLI · error · ArgumentError
packagist ${label} must be <= ${maxValue}
Error message
packagist ${label} must be <= ${maxValue} What it means
requireBoundedInt throws this ArgumentError when the value is a valid positive integer but exceeds the maxValue bound passed by the caller (e.g. a maximum page size for `limit`). It prevents abusive or accidentally huge requests to Packagist. The message includes the exact allowed maximum.
Source
Thrown at clis/packagist/utils.js:27
const UA = 'opencli-packagist-adapter (+https://github.com/jackwener/opencli)';
// Each segment of a Composer package name (`vendor` and `package`).
const SEGMENT = /^[a-z0-9]([_.-]?[a-z0-9]+)*$/;
export function requireString(value, label) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError(`packagist ${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(`packagist ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`packagist ${label} must be <= ${maxValue}`);
}
return n;
}
export function requirePackageName(value) {
const raw = String(value ?? '').trim().toLowerCase();
if (!raw) {
throw new ArgumentError('packagist package name is required (e.g. "symfony/console", "monolog/monolog")');
}
const slash = raw.indexOf('/');
if (slash <= 0 || slash === raw.length - 1) {
throw new ArgumentError(
`packagist package "${value}" must be "<vendor>/<package>"`,
'Both segments are required (Composer convention).',
);
}
const vendor = raw.slice(0, slash);
const pkg = raw.slice(slash + 1);View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the value so it is <= the maxValue reported in the message.
- Clamp programmatically: Math.min(n, maxValue) before calling.
- Read the adapter docs for the supported limit range and adjust your config.
- Catch ArgumentError and retry with the maximum allowed value.
Example fix
// before
run({ limit: 1000 }); // exceeds max
// after
run({ limit: Math.min(Number(opts.limit), 100) }); Defensive patterns
Strategy: validation
Validate before calling
const MAX_LIMIT = 100;
function clampLimit(v) {
const n = Number(v);
return Math.min(Math.max(1, Math.floor(n) || 1), MAX_LIMIT);
} Type guard
const isIntWithin = (v, max) => Number.isInteger(v) && v > 0 && v <= max;
Try / catch
try {
await run({ limit });
} catch (e) {
const m = /must be <= (\d+)/.exec(e.message);
if (e instanceof ArgumentError && m) {
return run({ limit: Number(m[1]) });
}
throw e;
} Prevention
- Clamp user-supplied limits against the documented maximum before calling.
- Parse the maxValue from the error message and retry at the boundary if acceptable.
- Keep one shared constant for the limit cap across your tooling.
- Note the cap in CLI help/config comments.
When it happens
Trigger: Calling limit with a value above the configured max, e.g. requireBoundedInt(1000, 10, 100, 'limit') — 1000 > maxValue 100.
Common situations: User passes --limit 99999 thinking more is better; a script copies a limit from another API with a larger ceiling; a hardcoded constant exceeds the adapter's cap after a library update lowered maxValue.
Related errors
- lichess ${label} must be <= ${maxValue}
- ${label} must be <= ${maxValue}
- --${name} must be between ${min} and ${max}, got ${parsed}
- INVALID_LIMIT
- juejin ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bdfdbe036bd3b1e8.
Report an issue: GitHub.