{"record":{"id":"04f535d0c9b94daf","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-04f535","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/rfc/utils.js","lineNumber":40,"sourceCode":"    if (!Number.isInteger(n) || n <= 0 || String(n) !== s) {\n        throw new ArgumentError(\n            `rfc number \"${value}\" is not a valid RFC number`,\n            'Pass a positive integer (e.g. 9000, 791, 2616).',\n        );\n    }\n    if (n > 999999) {\n        throw new ArgumentError('rfc number must be <= 999999');\n    }\n    return n;\n}\n\nexport async function rfcFetch(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 datatracker.ietf.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `IETF datatracker 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":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/rfc/utils.js#L22-L58","documentation":"rfcFetch wraps the fetch call to the IETF datatracker. When the request fails at the network level (DNS failure, connection refused, TLS error, timeout) it throws CommandExecutionError including the label and underlying error message, advising that datatracker.ietf.org may be unreachable.","triggerScenarios":"Any fetch() rejection: no internet connection, DNS unable to resolve datatracker.ietf.org, blocked egress on corporate networks/proxies, or TLS interception failures.","commonSituations":"Working offline, VPN/proxy blocking the request, firewall rules in CI environments, or transient datatracker outages.","solutions":["Check network connectivity (curl https://datatracker.ietf.org/doc/rfc9000/doc.json).","Verify DNS resolution and any proxy settings (HTTPS_PROXY etc.).","Retry after transient network issues; consider adding retry/backoff.","Catch CommandExecutionError and surface the hint about datatracker reachability."],"exampleFix":"// before\n// no handling\nconst doc = await rfcFetch(url, 'rfc 9000');\n// after\ntry {\n  const doc = await rfcFetch(url, 'rfc 9000');\n} catch (e) {\n  console.error('Datatracker unreachable, check network/proxy:', e.message);\n}","handlingStrategy":"retry","validationCode":"// Optional pre-check\nconst reachable = await fetch('https://datatracker.ietf.org/', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!reachable) console.warn('datatracker.ietf.org unreachable');","typeGuard":"null","tryCatchPattern":"async function fetchWithRetry(url, label, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try {\n      return await rfcFetch(url, label);\n    } catch (err) {\n      const transient = err instanceof CommandExecutionError && /request failed/.test(err.message);\n      if (!transient || i === attempts - 1) throw err;\n      await new Promise(r => setTimeout(r, 2 ** i * 500));\n    }\n  }\n}","preventionTips":["Check network/proxy availability before bulk lookups.","Set HTTPS_PROXY correctly on corporate networks.","Add retry with exponential backoff for transient failures.","Cache RFC metadata locally to reduce network dependence."],"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"}