jackwener/OpenCLI · error · ArgumentError
nuget ${label} must be <= ${maxValue}
Error message
nuget ${label} must be <= ${maxValue} What it means
This ArgumentError is thrown by requireBoundedInt in clis/nuget/utils.js when the supplied value is a valid positive integer but exceeds the maxValue bound for that option. The library caps paging limits (e.g. limit) to what the NuGet API sensibly supports, and rejects anything above the cap with this message. The maxValue for each option is fixed by the calling adapter.
Source
Thrown at clis/nuget/utils.js:31
// NuGet ID grammar (NuGet docs §package-id): up to 100 chars, alnum + `.` + `_` + `-`,
// must start with letter/digit. Case-insensitive; we lowercase for the registration URL
// because NuGet's CDN is case-sensitive on the path.
const PACKAGE_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,99})$/;
export function requireString(value, label) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError(`nuget ${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(`nuget ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`nuget ${label} must be <= ${maxValue}`);
}
return n;
}
export function requirePackageId(value) {
const raw = String(value ?? '').trim();
if (!raw) throw new ArgumentError('nuget package id is required (e.g. "Newtonsoft.Json")');
if (!PACKAGE_ID_PATTERN.test(raw)) {
throw new ArgumentError(
`nuget package id "${value}" is not a valid NuGet identifier`,
'NuGet IDs are 1-100 chars: letters/digits/`.`/`_`/`-`, starting with letter or digit.',
);
}
return raw;
}
export async function nugetFetch(url, label) {
let resp;View on GitHub (pinned to 49907e53dc)
Solutions
- Reduce the option value to at or below the max stated in the message, e.g. limit: 100
- Page through results with multiple calls (offset/cursor) instead of one giant limit
- Omit the option to use the safe default value
Example fix
// before
await nuget.limit(ctx, { limit: 5000 });
// after
await nuget.limit(ctx, { limit: 100 }); // check the adapter's documented max Defensive patterns
Strategy: validation
Validate before calling
const MAX_LIMIT = 100; // check the adapter's documented max if (Number(opts.limit) > MAX_LIMIT) opts.limit = MAX_LIMIT;
Type guard
function isWithinMax(v, max) { const n = typeof v === 'number' ? v : Number(v); return Number.isInteger(n) && n > 0 && n <= max; } Try / catch
try {
await nuget.limit(ctx, { limit });
} catch (e) {
if (e instanceof ArgumentError && /must be <= (\d+)/.test(e.message)) {
limit = Number(e.message.match(/must be <= (\d+)/)[1]); // clamp to max and retry
} else throw e;
} Prevention
- Clamp user-supplied limits to the documented maximum before calling
- Paginate instead of requesting one huge page
- Document the max in your own CLI's --help text
- Read the max from the error message and auto-clamp
When it happens
Trigger: Calling a nuget command with limit (or another labeled bounded option) set to a positive integer above the adapter's maximum, e.g. limit: 10000 when the cap is 100.
Common situations: Users asking for 'all results' via a huge page size; bulk scripts exporting the full package list in one call; misreading documentation about the maximum page size.
Related errors
- ${label} must be <= ${maxValue}
- arxiv ${label} must be <= ${maxValue}
- dblp ${label} must be <= ${maxValue}
- limit must be <= ${max}
- hf datasets limit must be <= 100
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/78bb0202abc385ee.
Report an issue: GitHub.