{"record":{"id":"d489edcd72f60bfa","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-d489ed","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/oeis/utils.js","lineNumber":52,"sourceCode":"    if (!raw) throw new ArgumentError('oeis sequence id is required (e.g. \"A000045\" for Fibonacci)');\n    // Tolerate common URL paste like `https://oeis.org/A000045`.\n    const stripped = raw.replace(/^HTTPS?:\\/\\/(?:WWW\\.)?OEIS\\.ORG\\//, '').replace(/\\/.*$/, '');\n    if (!SEQUENCE_ID_PATTERN.test(stripped)) {\n        throw new ArgumentError(\n            `oeis sequence id \"${value}\" is not a valid A-number`,\n            'Expected format: \"A\" + digits (e.g. \"A000045\").',\n        );\n    }\n    return stripped;\n}\n\nexport async function oeisFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that oeis.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `OEIS returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(`${label} returned HTTP 429 (rate limited)`);\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);\n    }\n    let body;\n    try {\n        body = await resp.json();\n    }\n    catch (err) {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/oeis/utils.js#L34-L70","documentation":"oeisFetch wraps its fetch() call; if the request to oeis.org throws at the network level (DNS failure, connection refused, TLS error, timeout), it rethrows as a CommandExecutionError with the underlying message and a hint to check network reachability. This distinguishes connectivity problems from HTTP status errors handled later.","triggerScenarios":"Any OEIS request when oeis.org is unreachable: no internet connection, DNS resolution failure, firewall/proxy blocking, or a TLS handshake failure.","commonSituations":"Working offline, corporate proxy without proper env vars (HTTPS_PROXY), DNS misconfiguration, or transient oeis.org outage.","solutions":["Verify network connectivity, e.g. `curl -I https://oeis.org`.","Check proxy settings (HTTPS_PROXY/HTTP_PROXY) if behind a corporate network.","Retry after confirming oeis.org status; the message contains the underlying cause."],"exampleFix":"// before (offline)\noeis search fibonacci\n// after\nexport HTTPS_PROXY=http://proxy.corp:8080\noeis search fibonacci","handlingStrategy":"try-catch","validationCode":"// Pre-flight reachability check\nconst res = await fetch('https://oeis.org', { method: 'HEAD' }).catch(() => null);\nif (!res) throw new Error('oeis.org is unreachable from this network');","typeGuard":"null","tryCatchPattern":"try { const data = await oeisFetch(url, label); } catch (e) { if (String(e.message).includes('request failed')) console.error('Network problem, check connectivity/proxy:', e.message); else throw e; }","preventionTips":["Set HTTPS_PROXY/HTTP_PROXY correctly on restricted networks.","Add a retry with exponential backoff for transient network failures.","Verify DNS/connectivity with `curl -I https://oeis.org` before bulk runs."],"tags":["network","fetch","connectivity"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}