{"record":{"id":"04eedbe49b72f70f","repo":"jackwener/OpenCLI","slug":"hf-datasets-request-failed-error-message-er","errorCode":null,"errorMessage":"hf datasets request failed: ${error?.message || error}","messagePattern":"hf datasets request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/hf/datasets.js","lineNumber":56,"sourceCode":"        }\n\n        const url = new URL('https://huggingface.co/api/datasets');\n        url.searchParams.set('sort', sort);\n        url.searchParams.set('direction', '-1');\n        url.searchParams.set('limit', String(limit));\n        url.searchParams.set('full', 'true');\n        if (args.search) url.searchParams.set('search', String(args.search));\n\n        let resp;\n        try {\n            resp = await fetch(url, {\n                headers: {\n                    'Accept': 'application/json',\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                },\n            });\n        } catch (error) {\n            throw new CommandExecutionError(`hf datasets request failed: ${error?.message || error}`);\n        }\n        if (!resp.ok) {\n            throw new CommandExecutionError(`hf datasets failed: HTTP ${resp.status}`);\n        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`hf datasets returned malformed JSON: ${error?.message || error}`);\n        }\n        const list = Array.isArray(data) ? data : [];\n        if (list.length === 0) {\n            throw new EmptyResultError('hf datasets', 'No matching datasets on huggingface.co.');\n        }\n        return list.slice(0, limit).map((d, i) => {\n            const id = d.id || '';\n            const slashIdx = id.indexOf('/');\n            const author = slashIdx > 0 ? id.slice(0, slashIdx) : '';","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/hf/datasets.js#L38-L74","documentation":"The fetch to https://huggingface.co/api/datasets threw (network-level failure), so the command wraps it in a CommandExecutionError with 'hf datasets request failed: ...' and the underlying error message. This is a transport failure, not an HTTP status error.","triggerScenarios":"fetch rejects: DNS resolution failure, connection refused/timeout, TLS error, offline machine, or request cancellation while fetching the datasets API.","commonSituations":"No internet or firewall blocking huggingface.co; corporate proxy without CA certs causing TLS errors; DNS misconfiguration; HF briefly unreachable.","solutions":["Check network connectivity and that huggingface.co is reachable (curl https://huggingface.co/api/datasets)","Read the underlying message after 'request failed:' for the specific cause (DNS/TLS/timeout)","Configure proxy/HTTPS_PROXY and CA bundle correctly in restricted networks","Retry after transient outages; add timeout/retry around the command"],"exampleFix":"// before\nconst resp = await fetch(url); // may reject\n// after\ntry { const resp = await fetch(url); } catch (e) { console.error('network issue:', e.message); process.exit(1); }","handlingStrategy":"retry","validationCode":"const reachable = await fetch('https://huggingface.co', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!reachable) throw new Error('huggingface.co unreachable; check network/proxy');","typeGuard":null,"tryCatchPattern":"try { await hfDatasets(args); } catch (e) { if (String(e.message).includes('request failed:')) { await sleep(2000); return retry(hfDatasets, args, 3); } throw e; }","preventionTips":["Pre-check connectivity to huggingface.co","Configure HTTPS_PROXY and CA bundles in corporate networks","Add retry with exponential backoff for transient network errors","Set explicit fetch timeouts"],"tags":["network","fetch","huggingface","api"],"backgroundTag":"fetch-network-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}