jackwener/OpenCLI · error · ArgumentError
arxiv ${label} must be <= ${maxValue}
Error message
arxiv ${label} must be <= ${maxValue} What it means
ArgumentError thrown by normalizeArxivLimit when the limit is a valid positive integer but exceeds maxValue, the API's upper bound for that option. The library caps limits to protect against oversized arXiv queries that would be rejected or time out.
Source
Thrown at clis/arxiv/utils.js:24
*/
import { ArgumentError, CommandExecutionError } from '@jackwener/opencli/errors';
export const ARXIV_BASE = 'https://export.arxiv.org/api/query';
const ARXIV_CATEGORY_PATTERN = /^[a-z]+(?:-[a-z]+)*(?:\.[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/;
export async function arxivFetch(params) {
const resp = await fetch(`${ARXIV_BASE}?${params}`);
if (!resp.ok) {
throw new CommandExecutionError(`arXiv API HTTP ${resp.status}`, 'Check your search term or paper ID');
}
return resp.text();
}
export function normalizeArxivLimit(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;
const limit = Number(raw);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError(`arxiv ${label} must be a positive integer`);
}
if (limit > maxValue) {
throw new ArgumentError(`arxiv ${label} must be <= ${maxValue}`);
}
return limit;
}
export function normalizeArxivCategory(value) {
const category = String(value || '').trim();
if (!ARXIV_CATEGORY_PATTERN.test(category)) {
throw new ArgumentError(`Invalid arXiv category "${value}". Examples: cs.CL, cs.LG, math.PR, q-bio.NC, physics.comp-ph`);
}
return category;
}
/** Decode the small set of XML entities arXiv emits in text fields. */
function decodeEntities(s) {
return s
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, "'")View on GitHub (pinned to 49907e53dc)
Solutions
- Lower the limit to the command's maximum and paginate if more results are needed.
- Check the command help for the max value of the limit option.
- For bulk needs, run multiple queries (e.g. by category or date range) each within the cap.
Example fix
// before opencli arxiv search 'llm' --limit 1000 // after opencli arxiv search 'llm' --limit 100
Defensive patterns
Strategy: validation
Validate before calling
const MAX_LIMIT = 100; // per command help if (limit > MAX_LIMIT) limit = MAX_LIMIT; // or paginate instead
Type guard
function isWithinLimit(n, max) {
return Number.isInteger(n) && n > 0 && n <= max;
} Try / catch
try {
await run(['arxiv', 'search', term, '--limit', String(limit)]);
} catch (e) {
const m = e.message.match(/must be <= (\d+)/);
if (m) {
limit = Number(m[1]); // clamp to the documented maximum
} else throw e;
} Prevention
- Read the command's help output for the documented maximum before scripting.
- Paginate multiple smaller queries instead of one huge limit.
- Clamp user-supplied limits to the max in wrapper scripts.
When it happens
Trigger: Calling a search/list command with a limit above the command's maximum (e.g. --limit 500 when max_results is capped at 100 or 200).
Common situations: Users trying to bulk-download results in one call; copying a limit from another tool with a higher cap; scripts paginating by requesting huge limits instead of using arXiv paging.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ${label} must be <= ${maxValue}
- dblp ${label} must be <= ${maxValue}
- limit must be <= ${max}
- hf datasets limit must be <= 100
- nuget ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/455179889bf9410d.
Report an issue: GitHub.