{"record":{"id":"167ebf1034c6529e","repo":"jackwener/OpenCLI","slug":"hf-paper-id-args-id-is-not-a-valid-arxiv-id","errorCode":null,"errorMessage":"hf paper id \"${args.id}\" is not a valid arXiv id","messagePattern":"hf paper id \"(.+?)\" is not a valid arXiv id","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/hf/paper.js","lineNumber":27,"sourceCode":"cli({\n    site: 'hf',\n    name: 'paper',\n    access: 'read',\n    description: 'Hugging Face paper detail by arXiv id (full title / summary / authors / AI keywords)',\n    domain: 'huggingface.co',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'id', positional: true, required: true, help: 'arXiv id (e.g. \"1706.03762\") — same value HF uses to mirror the paper' },\n    ],\n    columns: ['id', 'title', 'authors', 'publishedAt', 'upvotes', 'aiKeywords', 'summary', 'aiSummary', 'url'],\n    func: async (args) => {\n        const raw = String(args.id ?? '').trim();\n        if (!raw) {\n            throw new ArgumentError('hf paper id cannot be empty', 'Example: opencli hf paper 1706.03762');\n        }\n        if (!ARXIV_ID_PATTERN.test(raw)) {\n            throw new ArgumentError(\n                `hf paper id \"${args.id}\" is not a valid arXiv id`,\n                'Expected the modern arXiv form `YYMM.NNNNN` (optionally with a version suffix like `v3`).',\n            );\n        }\n        const endpoint = process.env.HF_ENDPOINT?.replace(/\\/+$/, '') || 'https://huggingface.co';\n        const url = `${endpoint}/api/papers/${encodeURIComponent(raw)}`;\n        let resp;\n        try {\n            resp = await fetch(url, { headers: { accept: 'application/json' } });\n        }\n        catch (err) {\n            throw new CommandExecutionError(`hf paper request failed: ${err?.message ?? err}`);\n        }\n        if (resp.status === 404) {\n            throw new EmptyResultError('hf paper', `Hugging Face has no paper page for \"${raw}\".`);\n        }\n        if (resp.status === 429) {\n            throw new CommandExecutionError(","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/paper.js#L9-L45","documentation":"ArgumentError thrown at clis/hf/paper.js:27 when the provided `id` argument does not match ARXIV_ID_PATTERN /^\\d{4}\\.\\d{4,5}(?:v\\d+)?$/ — the modern arXiv form YYMM.NNNNN with an optional version suffix (v3). The library validates the format client-side before calling ${HF_ENDPOINT}/api/papers/<id>, since old-style ids or URLs will never resolve there.","triggerScenarios":"Passing an old-style arXiv id ('cs.CL/0301012' or 'math/0209477'); passing a full URL ('https://arxiv.org/abs/1706.03762') instead of the bare id; missing the dot ('170603762'); an invalid month ('1713.03762'); too many/too few digits ('1706.037' or '1706.0376234'); a trailing filename ('1706.03762.pdf').","commonSituations":"Copying the whole arXiv URL or a PDF filename from the browser; dealing with pre-2007 papers that use the legacy category-based id scheme; paste artifacts adding spaces or quotes; passing a DOI or Semantic Scholar id by mistake.","solutions":["Convert the input to the bare modern id: YYMM.NNNNN, e.g. 1706.03762 (strip any https://arxiv.org/abs/ prefix and .pdf).","For legacy pre-2007 ids, look the paper up on arxiv.org to find its modern equivalent id before calling `hf paper`.","If a version matters, append it like 1706.03762v3; otherwise omit the version suffix.","Sanitize scripted inputs: strip whitespace/quotes and validate with /^\\d{4}\\.\\d{4,5}(v\\d+)?$/ before invoking."],"exampleFix":"// before\nopencli hf paper https://arxiv.org/abs/1706.03762v1\n// after\nopencli hf paper 1706.03762","handlingStrategy":"validation","validationCode":"const ARXIV_ID_PATTERN = /^\\d{4}\\.\\d{4,5}(?:v\\d+)?$/;\nfunction validateArxivId(raw) {\n  const id = String(raw ?? '').trim().replace(/^https?:\\/\\/arxiv\\.org\\/(abs|pdf)\\//, '').replace(/\\.pdf$/i, '');\n  if (!ARXIV_ID_PATTERN.test(id)) throw new Error(`Expected YYMM.NNNNN (optional vN), got: ${raw}`);\n  return id;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await run(`hf paper ${id}`);\n} catch (e) {\n  if (String(e.message).includes('is not a valid arXiv id')) {\n    const bare = String(id).replace(/^https?:\\/\\/arxiv\\.org\\/(abs|pdf)\\//, '').replace(/\\.pdf$/i, '');\n    if (/^\\d{4}\\.\\d{4,5}(v\\d+)?$/.test(bare)) await run(`hf paper ${bare}`);\n    else console.error('Provide a modern arXiv id like 1706.03762 (legacy cs/0301012 ids are not supported)');\n  } else throw e;\n}","preventionTips":["Pass the bare id, never the arxiv.org URL or a .pdf filename.","Convert legacy pre-2007 ids (cs/0301012) via arxiv.org first.","Validate with /^\\d{4}\\.\\d{4,5}(v\\d+)?$/ in wrappers.","Strip whitespace/quotes from pasted values before passing."],"tags":["argument-validation","cli","format-validation","huggingface"],"backgroundTag":"invalid-id-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}