{"record":{"id":"5bbbeb105c13a3a5","repo":"jackwener/OpenCLI","slug":"invalid-arxiv-category-value-examples-cs-cl","errorCode":null,"errorMessage":"Invalid arXiv category \"${value}\". Examples: cs.CL, cs.LG, math.PR, q-bio.NC, physics.comp-ph","messagePattern":"Invalid arXiv category \"(.+?)\"\\. Examples: cs\\.CL, cs\\.LG, math\\.PR, q-bio\\.NC, physics\\.comp-ph","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/arxiv/utils.js","lineNumber":31,"sourceCode":"        throw new CommandExecutionError(`arXiv API HTTP ${resp.status}`, 'Check your search term or paper ID');\n    }\n    return resp.text();\n}\nexport function normalizeArxivLimit(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const limit = Number(raw);\n    if (!Number.isInteger(limit) || limit <= 0) {\n        throw new ArgumentError(`arxiv ${label} must be a positive integer`);\n    }\n    if (limit > maxValue) {\n        throw new ArgumentError(`arxiv ${label} must be <= ${maxValue}`);\n    }\n    return limit;\n}\nexport function normalizeArxivCategory(value) {\n    const category = String(value || '').trim();\n    if (!ARXIV_CATEGORY_PATTERN.test(category)) {\n        throw new ArgumentError(`Invalid arXiv category \"${value}\". Examples: cs.CL, cs.LG, math.PR, q-bio.NC, physics.comp-ph`);\n    }\n    return category;\n}\n/** Decode the small set of XML entities arXiv emits in text fields. */\nfunction decodeEntities(s) {\n    return s\n        .replace(/&amp;/g, '&')\n        .replace(/&lt;/g, '<')\n        .replace(/&gt;/g, '>')\n        .replace(/&quot;/g, '\"')\n        .replace(/&apos;/g, \"'\")\n        .replace(/&#39;/g, \"'\");\n}\n/** Extract the text content of the first matching XML tag. */\nfunction extract(xml, tag) {\n    const m = xml.match(new RegExp(`<${tag}[^>]*>([\\\\s\\\\S]*?)<\\\\/${tag}>`));\n    return m ? m[1].trim() : '';\n}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/arxiv/utils.js#L13-L49","documentation":"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.","triggerScenarios":"Passing a category like 'cs cl', 'CS.CL' (uppercase prefix), 'cs', 'cats.CL', or one containing invalid characters to a command's category option.","commonSituations":"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.","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."],"exampleFix":"// before\nopencli arxiv category 'CS.CL' --limit 5\n// after\nopencli arxiv category 'cs.CL' --limit 5","handlingStrategy":"validation","validationCode":"const CAT_RE = /^[a-z]+(?:-[a-z]+)*(?:\\.[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/;\nif (!CAT_RE.test(category)) throw new Error(`invalid arXiv category: ${category}`);","typeGuard":"function isValidArxivCategory(v) {\n  return typeof v === 'string' && /^[a-z]+(?:-[a-z]+)*(?:\\.[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)?$/.test(v.trim());\n}","tryCatchPattern":"try {\n  await run(['arxiv', 'category', category]);\n} catch (e) {\n  if (/Invalid arXiv category/.test(e.message)) {\n    console.error('Use taxonomy ids like cs.CL, cs.LG — see arxiv.org/category_taxonomy');\n  } else throw e;\n}","preventionTips":["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)."],"tags":["validation","arguments","arxiv"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}