jackwener/OpenCLI · error · ArgumentError
Invalid arXiv category "${value}". Examples: cs.CL, cs.LG, m
Error message
Invalid arXiv category "${value}". Examples: cs.CL, cs.LG, math.PR, q-bio.NC, physics.comp-ph What it means
ArgumentError thrown by normalizeArxivCategory when the category string does not match ARXIV_CATEGORY_PATTERN (archive or archive.subcategory like cs.CL, possibly with hyphens). The library validates categories client-side so invalid ones never reach the arXiv API.
Source
Thrown at clis/arxiv/utils.js:31
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, "'")
.replace(/'/g, "'");
}
/** Extract the text content of the first matching XML tag. */
function extract(xml, tag) {
const m = xml.match(new RegExp(`<${tag}[^>]*>([\\s\\S]*?)<\\/${tag}>`));
return m ? m[1].trim() : '';
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use a valid arXiv taxonomy id such as cs.CL, cs.LG, math.PR, q-bio.NC, physics.comp-ph.
- Lowercase the archive part and join archive + subcategory with a dot (e.g. cs.CL).
- Look up the exact category at arxiv.org/category_taxonomy.
Example fix
// before opencli arxiv category 'CS.CL' --limit 5 // after opencli arxiv category 'cs.CL' --limit 5
Defensive patterns
Strategy: validation
Validate before calling
const CAT_RE = /^[a-z]+(?:-[a-z]+)*(?:\.[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/;
if (!CAT_RE.test(category)) throw new Error(`invalid arXiv category: ${category}`); Type guard
function isValidArxivCategory(v) {
return typeof v === 'string' && /^[a-z]+(?:-[a-z]+)*(?:\.[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/.test(v.trim());
} Try / catch
try {
await run(['arxiv', 'category', category]);
} catch (e) {
if (/Invalid arXiv category/.test(e.message)) {
console.error('Use taxonomy ids like cs.CL, cs.LG — see arxiv.org/category_taxonomy');
} else throw e;
} Prevention
- Keep a whitelist of valid arXiv category ids in your tooling.
- Lowercase the archive part and use a dot before the subcategory.
- Consult arxiv.org/category_taxonomy for current names (categories get renamed/deprecated).
When it happens
Trigger: Passing a category like 'cs cl', 'CS.CL' (uppercase prefix), 'cs', 'cats.CL', or one containing invalid characters to a command's category option.
Common situations: Typos or old/renamed arXiv categories (e.g. deprecated q-bio forms); using human names ('machine learning') instead of taxonomic IDs; uppercase input from Windows scripts.
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} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- arxiv author cannot be empty
- No recent papers in ${category}. Check the category name.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5bbbeb105c13a3a5.
Report an issue: GitHub.