jackwener/OpenCLI · error · CommandExecutionError

hf paper request failed: ${err?.message ?? err}

Error message

hf paper request failed: ${err?.message ?? err}

What it means

Thrown by the `hf paper` CLI command when the underlying fetch() to `${HF_ENDPOINT||https://huggingface.co}/api/papers/<arxiv-id>` rejects (network-level failure, not an HTTP status). The command wraps the raw cause (err?.message ?? err) in a CommandExecutionError because the request never produced a response to inspect.

Source

Thrown at clis/hf/paper.js:39

    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(
                '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) {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check basic connectivity: curl -sS https://huggingface.co/api/papers/1706.03762 to confirm the endpoint is reachable from this machine.
  2. If HF_ENDPOINT is set, unset it or correct it (export HF_ENDPOINT=https://huggingface.co) — a trailing-slash-free, valid base URL is required.
  3. Check proxy settings (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) if behind a corporate network; configure fetch-compatible proxy env vars.
  4. Retry after a few seconds if the failure was a transient network blip (fetch has no built-in retry here).
  5. Inspect the wrapped cause message after 'hf paper request failed:' — it names the actual socket/DNS/TLS error to fix.

Example fix

// before (shell, broken mirror)
export HF_ENDPOINT=https://hf-mirror.example.invalid
opencli hf paper 1706.03762
// after
unset HF_ENDPOINT   # or point at a live mirror
opencli hf paper 1706.03762
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight reachability check before invoking the command
const ok = await fetch('https://huggingface.co/api/papers/1706.03762', { method: 'HEAD' }).then(r => true).catch(() => false);
if (!ok) throw new Error('huggingface.co unreachable — check network/HF_ENDPOINT/proxy');

Type guard

function isCommandExecutionError(e) {
  return e instanceof Error && e.name === 'CommandExecutionError';
}

Try / catch

try {
  await run(['opencli', 'hf paper', id]);
} catch (e) {
  if (String(e.message).startsWith('hf paper request failed:')) {
    // network-level: check connectivity / HF_ENDPOINT, then retry with backoff
  } else throw e;
}

Prevention

When it happens

Trigger: fetch() rejects: DNS resolution failure for huggingface.co, no network interface/connectivity, TLS handshake failure, connection reset/timeout, or an invalid/unreachable HF_ENDPOINT value (e.g. a typo'd mirror URL or a proxy host that is down).

Common situations: Developer is offline or behind a corporate proxy that blocks huggingface.co; HF_ENDPOINT env var set to a dead or mistyped mirror; DNS issues in a container/CI environment; transient HF outage dropping connections.

Related errors


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