jackwener/OpenCLI · error · ArgumentError

hf paper id "${args.id}" is not a valid arXiv id

Error message

hf paper id "${args.id}" is not a valid arXiv id

What it means

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.

Source

Thrown at clis/hf/paper.js:27

cli({
    site: 'hf',
    name: 'paper',
    access: 'read',
    description: 'Hugging Face paper detail by arXiv id (full title / summary / authors / AI keywords)',
    domain: 'huggingface.co',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'id', positional: true, required: true, help: 'arXiv id (e.g. "1706.03762") — same value HF uses to mirror the paper' },
    ],
    columns: ['id', 'title', 'authors', 'publishedAt', 'upvotes', 'aiKeywords', 'summary', 'aiSummary', 'url'],
    func: async (args) => {
        const raw = String(args.id ?? '').trim();
        if (!raw) {
            throw new ArgumentError('hf paper id cannot be empty', 'Example: opencli hf paper 1706.03762');
        }
        if (!ARXIV_ID_PATTERN.test(raw)) {
            throw new ArgumentError(
                `hf paper id "${args.id}" is not a valid arXiv id`,
                'Expected the modern arXiv form `YYMM.NNNNN` (optionally with a version suffix like `v3`).',
            );
        }
        const endpoint = process.env.HF_ENDPOINT?.replace(/\/+$/, '') || 'https://huggingface.co';
        const url = `${endpoint}/api/papers/${encodeURIComponent(raw)}`;
        let resp;
        try {
            resp = await fetch(url, { headers: { accept: 'application/json' } });
        }
        catch (err) {
            throw new CommandExecutionError(`hf paper request failed: ${err?.message ?? err}`);
        }
        if (resp.status === 404) {
            throw new EmptyResultError('hf paper', `Hugging Face has no paper page for "${raw}".`);
        }
        if (resp.status === 429) {
            throw new CommandExecutionError(

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Convert the input to the bare modern id: YYMM.NNNNN, e.g. 1706.03762 (strip any https://arxiv.org/abs/ prefix and .pdf).
  2. For legacy pre-2007 ids, look the paper up on arxiv.org to find its modern equivalent id before calling `hf paper`.
  3. If a version matters, append it like 1706.03762v3; otherwise omit the version suffix.
  4. Sanitize scripted inputs: strip whitespace/quotes and validate with /^\d{4}\.\d{4,5}(v\d+)?$/ before invoking.

Example fix

// before
opencli hf paper https://arxiv.org/abs/1706.03762v1
// after
opencli hf paper 1706.03762
Defensive patterns

Strategy: validation

Validate before calling

const ARXIV_ID_PATTERN = /^\d{4}\.\d{4,5}(?:v\d+)?$/;
function validateArxivId(raw) {
  const id = String(raw ?? '').trim().replace(/^https?:\/\/arxiv\.org\/(abs|pdf)\//, '').replace(/\.pdf$/i, '');
  if (!ARXIV_ID_PATTERN.test(id)) throw new Error(`Expected YYMM.NNNNN (optional vN), got: ${raw}`);
  return id;
}

Try / catch

try {
  await run(`hf paper ${id}`);
} catch (e) {
  if (String(e.message).includes('is not a valid arXiv id')) {
    const bare = String(id).replace(/^https?:\/\/arxiv\.org\/(abs|pdf)\//, '').replace(/\.pdf$/i, '');
    if (/^\d{4}\.\d{4,5}(v\d+)?$/.test(bare)) await run(`hf paper ${bare}`);
    else console.error('Provide a modern arXiv id like 1706.03762 (legacy cs/0301012 ids are not supported)');
  } else throw e;
}

Prevention

When it happens

Trigger: 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').

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/167ebf1034c6529e. Report an issue: GitHub.