{"record":{"id":"06d646db86ec0567","repo":"jackwener/OpenCLI","slug":"hf-paper-request-failed-err-message-err","errorCode":null,"errorMessage":"hf paper request failed: ${err?.message ?? err}","messagePattern":"hf paper request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hf/paper.js","lineNumber":39,"sourceCode":"    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(\n                'hf paper returned HTTP 429 (rate limited)',\n                'Hugging Face throttles unauthenticated traffic; wait a few seconds and retry.',\n            );\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`hf paper returned HTTP ${resp.status}`);\n        }\n        let body;\n        try {\n            body = await resp.json();\n        }\n        catch (err) {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/paper.js#L21-L57","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check basic connectivity: curl -sS https://huggingface.co/api/papers/1706.03762 to confirm the endpoint is reachable from this machine.","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.","Check proxy settings (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) if behind a corporate network; configure fetch-compatible proxy env vars.","Retry after a few seconds if the failure was a transient network blip (fetch has no built-in retry here).","Inspect the wrapped cause message after 'hf paper request failed:' — it names the actual socket/DNS/TLS error to fix."],"exampleFix":"// before (shell, broken mirror)\nexport HF_ENDPOINT=https://hf-mirror.example.invalid\nopencli hf paper 1706.03762\n// after\nunset HF_ENDPOINT   # or point at a live mirror\nopencli hf paper 1706.03762","handlingStrategy":"try-catch","validationCode":"// preflight reachability check before invoking the command\nconst ok = await fetch('https://huggingface.co/api/papers/1706.03762', { method: 'HEAD' }).then(r => true).catch(() => false);\nif (!ok) throw new Error('huggingface.co unreachable — check network/HF_ENDPOINT/proxy');","typeGuard":"function isCommandExecutionError(e) {\n  return e instanceof Error && e.name === 'CommandExecutionError';\n}","tryCatchPattern":"try {\n  await run(['opencli', 'hf paper', id]);\n} catch (e) {\n  if (String(e.message).startsWith('hf paper request failed:')) {\n    // network-level: check connectivity / HF_ENDPOINT, then retry with backoff\n  } else throw e;\n}","preventionTips":["Verify DNS/network reachability to huggingface.co before scripted runs.","Keep HF_ENDPOINT unset or pointing at a validated, live mirror URL.","Configure proxy env vars correctly when behind a corporate network.","Add retry-with-backoff around network calls in automation.","Log the wrapped cause message — it names the exact socket/DNS/TLS failure."],"tags":["network","fetch","huggingface","cli"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}