{"record":{"id":"d67554ecf51b54f4","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-d67554","errorCode":null,"errorMessage":"`${label} request failed: ${err?.message ?? err}`","messagePattern":"`(.+?) request failed: (.+?)`","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/endoflife/utils.js","lineNumber":48,"sourceCode":"export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`endoflife ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`endoflife ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport async function eolFetch(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 endoflife.date is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `endoflife.date returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'endoflife.date throttles unauthenticated traffic; wait a few seconds and retry.',\n        );\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);\n    }\n    let body;\n    try {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/endoflife/utils.js#L30-L66","documentation":"eolFetch wraps the underlying fetch() to endoflife.date; when the request itself throws (network failure), it rethrows as CommandExecutionError with the label and the original error message. This means the API was never reached — DNS, TCP, TLS, or connection-level failure — not an HTTP error response. The hint tells you to verify network reachability of endoflife.date.","triggerScenarios":"Any adapter call (e.g. cycles) invoking eolFetch while the machine is offline, DNS for endoflife.date fails, a proxy/firewall blocks the connection, or TLS interception breaks the handshake — fetch() rejects before a Response exists.","commonSituations":"Working behind a corporate proxy without HTTPS_PROXY configured; VPN or captive portal dropping traffic; DNS misconfiguration; endoflife.date outage or local firewall blocking outbound HTTPS.","solutions":["Verify connectivity: curl -I https://endoflife.date/api","Check DNS resolution of endoflife.date (nslookup / dig)","Set HTTPS_PROXY/HTTP_PROXY if behind a corporate proxy","Retry after confirming the network or endoflife.date status"],"exampleFix":"// before\n$ opencli endoflife cycles nodejs\nError: cycles request failed: getaddrinfo ENOTFOUND endoflife.date\n// after\n$ export HTTPS_PROXY=http://proxy.corp:8080\n$ opencli endoflife cycles nodejs   # succeeds","handlingStrategy":"try-catch","validationCode":"// pre-flight reachability check\nconst reachable = await fetch('https://endoflife.date/api', { method: 'HEAD' })\n  .then(() => true)\n  .catch(() => false);\nif (!reachable) throw new Error('endoflife.date unreachable; check network/proxy');","typeGuard":null,"tryCatchPattern":"try {\n  const data = await getCycles('nodejs');\n} catch (err) {\n  if (/request failed/.test(err.message)) {\n    // network-level failure: fall back to cache or retry later\n  } else throw err;\n}","preventionTips":["Configure HTTPS_PROXY when behind corporate proxies","Add a connectivity pre-check before batch lookups","Cache prior results so offline runs degrade gracefully","Monitor endoflife.date status in CI before running lookups"],"tags":["network","fetch","dns","connectivity"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}