{"record":{"id":"6d97c7dcdb79f4d7","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-url","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status} (${url})","messagePattern":"(.+?) returned HTTP (.+?) \\((.+?)\\)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/bbc/utils.js","lineNumber":68,"sourceCode":"        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":50,"sourceCodeEnd":80,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bbc/utils.js#L50-L80","documentation":"bbcFetchRss performs all HTTP fetches for the BBC news CLI against feeds.bbci.co.uk. When fetch succeeds but the response status is not ok (e.g. 404, 403, 5xx), the library throws this CommandExecutionError naming the feed label and the failing URL so the user knows exactly which BBC feed endpoint rejected the request.","triggerScenarios":"Calling any bbc CLI subcommand (via the xml path) whose feed URL returns a non-2xx HTTP status from feeds.bbci.co.uk, such as a renamed/removed feed slug or a feed temporarily returning 403/503.","commonSituations":"A mistyped or outdated feed label maps to a URL that now 404s; BBC edge/CDN returns 403 to datacenter or proxied networks; transient 5xx during BBC maintenance; corporate proxy blocking the domain.","solutions":["Verify the feed label/URL is a valid BBC RSS feed (test the URL in a browser or curl -I)","Check network/proxy reachability to feeds.bbci.co.uk (VPN, firewall, proxy env vars)","Retry later if the status is 5xx — often transient server-side","Inspect the resp.status in the message to target the exact failing endpoint"],"exampleFix":"// before\nconst resp = await fetch(url);\n// after\nconst resp = await fetch(url, { headers: { 'User-Agent': 'Mozilla/5.0' } });\nif (!resp.ok) console.error(`feed unavailable: ${resp.status}`);","handlingStrategy":"try-catch","validationCode":"const head = await fetch(url, { method: 'HEAD' });\nif (!head.ok) throw new Error(`BBC feed ${url} is unavailable (HTTP ${head.status})`);","typeGuard":"function isOk(resp) { return resp != null && typeof resp.ok === 'boolean' && resp.ok; }","tryCatchPattern":"try { await bbcFeed(label); } catch (e) { if (String(e.message).includes('returned HTTP')) { /* check URL/network, retry or skip */ } else throw e; }","preventionTips":["curl -I the feed URL before wiring it into scripts","Handle 403/5xx with backoff retries","Keep the feed label→URL map updated with valid BBC RSS endpoints"],"tags":["http","network","http-status","rss"],"backgroundTag":"http-non-2xx-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}