{"record":{"id":"67c44819f1df4a17","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-67c448","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bbc/utils.js","lineNumber":62,"sourceCode":"    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`bbc ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`bbc ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport async function bbcFetchRss(path, label) {\n    const url = `${BBC_FEED_BASE}/${path}`;\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/rss+xml, application/xml' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that feeds.bbci.co.uk is reachable from this network.',\n        );\n    }\n    if (!resp.ok) {\n        throw new CommandExecutionError(`${label} returned HTTP ${resp.status} (${url})`);\n    }\n    return resp.text();\n}\n\n/** Convert RFC-822 pubDate to ISO `YYYY-MM-DD`; empty string on parse failure. */\nexport function pubDateToIso(value) {\n    if (!value) return '';\n    const d = new Date(value);\n    if (Number.isNaN(d.getTime())) return '';\n    return d.toISOString().slice(0, 10);\n}\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bbc/utils.js#L44-L80","documentation":"CommandExecutionError from `bbcFetchRss` when the `fetch` call to feeds.bbci.co.uk throws (DNS failure, connection refused, TLS error, timeout) — i.e. the request never got an HTTP response. The label (e.g. 'bbc topic technology') plus the underlying err message are embedded to identify which feed failed and why.","triggerScenarios":"Any `bbc topic` call where the network request to `https://feeds.bbci.co.uk/<path>` fails at the transport layer: no internet, DNS resolution failure, corporate firewall blocking the domain, IPv6 issues, or fetch timeout.","commonSituations":"Offline development machines, VPN/proxy configurations that block feeds.bbci.co.uk, DNS misconfiguration, container/CI environments without network egress, TLS interception certificates not trusted by Node.","solutions":["Read the underlying `err.message` in the thrown error to identify the transport cause (ENOTFOUND, ECONNREFUSED, cert error, etc.).","Verify general internet connectivity and that https://feeds.bbci.co.uk loads in a browser/curl.","Fix DNS/proxy/VPN settings or allowlist feeds.bbci.co.uk on the network.","If in Node with custom TLS inspection, set NODE_EXTRA_CA_CERTS to the corporate CA bundle.","Add retry logic for transient network failures."],"exampleFix":"// before\nconst xml = await bbcFetchRss(`${raw}/rss.xml`, `bbc topic ${raw}`);\n// after\ntry {\n  const xml = await bbcFetchRss(`${raw}/rss.xml`, `bbc topic ${raw}`);\n} catch (e) {\n  if (/ENOTFOUND|ECONNREFUSED|ETIMEDOUT/.test(e.message)) {\n    console.error('Network unreachable; check connectivity to feeds.bbci.co.uk');\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"const reachable = await fetch('https://feeds.bbci.co.uk/news/rss.xml', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!reachable) throw new Error('feeds.bbci.co.uk unreachable — check network/DNS/proxy');","typeGuard":"const isNetworkError = (e) => /ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT|CERT|fetch failed/i.test(String(e?.cause?.code || e?.message));","tryCatchPattern":"try {\n  const xml = await bbcFetchRss(path, label);\n} catch (e) {\n  if (isNetworkError(e)) {\n    await new Promise(r => setTimeout(r, 2000));\n    // retry up to 3 times, then surface connectivity guidance\n  } else throw e;\n}","preventionTips":["Check connectivity to feeds.bbci.co.uk before batch fetches","Allowlist feeds.bbci.co.uk in firewalls/proxies","Set NODE_EXTRA_CA_CERTS behind TLS-intercepting proxies","Implement exponential-backoff retries for transient failures"],"tags":["bbc","network","rss","fetch"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}