jackwener/OpenCLI · error · ArgumentError
maven ${label} must be <= ${maxValue}
Error message
maven ${label} must be <= ${maxValue} What it means
`requireBoundedInt` enforces an upper bound and throws ArgumentError with `maven ${label} must be <= ${maxValue}` when the integer value exceeds it. For the `limit` argument the max is 200 (requireBoundedInt(args.limit, 30, 200)), so any limit > 200 is rejected.
Source
Thrown at clis/maven/utils.js:29
// Maven groupId / artifactId tokens — Java-package-ish (letters / digits /
// `_-.`), 1-200 chars; reverse-DNS dots are allowed in groupId.
const COORD_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
export function requireString(value, label) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError(`maven ${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(`maven ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`maven ${label} must be <= ${maxValue}`);
}
return n;
}
/**
* Parse a Maven coordinate `groupId:artifactId[:version]` into segments.
* groupId / artifactId are required; version is optional.
*/
export function requireCoord(value) {
const raw = String(value ?? '').trim();
if (!raw) {
throw new ArgumentError('maven coordinate is required (e.g. "com.fasterxml.jackson.core:jackson-databind")');
}
const parts = raw.split(':');
if (parts.length < 2 || parts.length > 3) {
throw new ArgumentError(
`maven coordinate "${value}" must be "groupId:artifactId" or "groupId:artifactId:version"`,
);View on GitHub (pinned to 49907e53dc)
Solutions
- Reduce the limit to <= 200 for maven search
- Paginate instead: issue multiple calls with limit 200 (or default 30) and aggregate results if you need more rows
- Clamp the value in your own code before calling: Math.min(maxAllowed, requested)
- Check the API/docs for the supported maximum rather than guessing
Example fix
// before
await mavenSearch({ query: 'jackson', limit: 1000 });
// after
const docs = await mavenSearch({ query: 'jackson', limit: 200 }); // paginate for more Defensive patterns
Strategy: validation
Validate before calling
function clampLimit(v, dflt = 30, max = 200) {
if (v == null) return dflt;
const n = typeof v === 'number' ? v : Number(v);
return Math.min(max, Math.max(1, n));
} Type guard
function isIntWithin(v, max) { return Number.isInteger(v) && v > 0 && v <= max; } Try / catch
try {
const docs = await mavenSearch({ query, limit });
} catch (err) {
if (err instanceof ArgumentError && /must be <= /.test(err.message)) {
console.error('limit exceeds the API cap (200); paginate instead');
return;
}
throw err;
} Prevention
- Clamp limits to the known maximum (200) before calling
- Paginate with multiple calls rather than requesting one huge page
- Don't reuse max values from other APIs' pagination schemes
- Document/encode the cap in your own CLI validation
When it happens
Trigger: Calling an operation with `limit` set to an integer greater than the maxValue allowed, e.g. `limit: 500` or `limit: 1000` for maven search. Only reached after the value already passed the positive-integer check.
Common situations: 'Fetch everything' attempts using an enormous limit; copying a max from a different API whose cap is higher (e.g. GitHub's 100 is fine here but 1000 is not); config shared across tools with different caps; not knowing the API's cap since it isn't in the error until you hit it.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- maven ${label} cannot be empty
- maven ${label} must be a positive integer
- maven coordinate is required (e.g. "com.fasterxml.jackson.co
- maven coordinate "${value}" must be "groupId:artifactId" or
- maven coordinate "${value}" is missing groupId or artifactId
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/33e6776455be5556.
Report an issue: GitHub.