jackwener/OpenCLI · warning · EmptyResultError

hf paper

Error message

hf paper

What it means

EmptyResultError('hf paper', 'Hugging Face has no paper page for "<raw>".') thrown when the Hugging Face /api/papers endpoint returns HTTP 404. It means the request succeeded but HF has no paper page for the given arXiv id — the library treats this as an 'empty result', not a hard failure.

Source

Thrown at clis/hf/paper.js:42

            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(
                'hf paper returned HTTP 429 (rate limited)',
                'Hugging Face throttles unauthenticated traffic; wait a few seconds and retry.',
            );
        }
        if (!resp.ok) {
            throw new CommandExecutionError(`hf paper returned HTTP ${resp.status}`);
        }
        let body;
        try {
            body = await resp.json();
        }
        catch (err) {
            throw new CommandExecutionError(`hf paper returned malformed JSON: ${err?.message ?? err}`);
        }
        if (!body || typeof body !== 'object' || !body.id) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the arXiv id on arxiv.org/abs/<id> — correct any typo and rerun.
  2. Drop the version suffix: try `opencli hf paper 1706.03762` instead of `1706.03762v3`.
  3. If the paper is brand new, wait and retry — HF generates paper pages after ingestion.
  4. Search HF papers (huggingface.co/papers) to confirm the mirror exists before querying.
  5. If you intended a full URL or title, convert it to the bare arXiv id first — the command only accepts ids.

Example fix

// before
opencli hf paper 1706.03762v2   // 404: versioned page missing
// after
opencli hf paper 1706.03762
Defensive patterns

Strategy: validation

Validate before calling

const ARXIV_ID = /^\d{4}\.\d{4,5}(v\d+)?$/;
if (!ARXIV_ID.test(id)) throw new Error(`not an arXiv id: ${id}`);
// optionally confirm the mirror exists first:
const res = await fetch(`https://huggingface.co/api/papers/${id}`);
if (res.status === 404) console.warn(`no HF paper page for ${id} — verify on arxiv.org/abs/${id}`);

Type guard

function isEmptyResultError(e) {
  return e instanceof Error && e.name === 'EmptyResultError';
}

Try / catch

try {
  await run(['opencli', 'hf paper', id]);
} catch (e) {
  if (String(e.message).includes('no paper page for')) {
    // treat as 'not found': validate id on arxiv.org, strip version suffix, or skip
  } else throw e;
}

Prevention

When it happens

Trigger: GET /api/papers/<id> returns 404: the arXiv id passed matches the YYMM.NNNNN pattern but HF has not mirrored that paper (very new, very obscure, or non-existent id), or the version suffix (e.g. v2) has no HF page.

Common situations: Developer typos an arXiv id (e.g. 1706.0376 vs 1706.03762); queries a brand-new paper before HF's paper page is generated; uses an id format that passes the regex but doesn't exist (e.g. wrong month/day digits).

Related errors


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