{"record":{"id":"47cb3f3c75cd830e","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-47cb3f","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/homebrew/utils.js","lineNumber":81,"sourceCode":"        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 formulae.brew.sh is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `Homebrew API returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'Homebrew throttles bursts; 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 {\n        body = await resp.json();\n    }\n    catch (err) {\n        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);\n    }\n    return body;\n}\n\n/** Coerce a count value (which Homebrew analytics serves as `\"139,972\"`) to a plain number. */\nexport function parseInstallCount(value) {\n    if (value == null) return null;\n    const s = String(value).replace(/,/g, '').trim();\n    if (!s) return null;\n    const n = Number(s);\n    return Number.isFinite(n) ? n : null;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/homebrew/utils.js#L63-L99","documentation":"brewFetch throws this generic CommandExecutionError for any non-OK HTTP status that isn't the specially-handled 404 or 429 — e.g. 500/502/503 from GitHub Pages, 403 from a WAF, or unusual proxies' error pages. The message carries the label and the raw status code since the API has no structured error body to surface.","triggerScenarios":"Any brewFetch-based call while formulae.brew.sh / GitHub Pages returns a 5xx outage or 403; a middlebox (corporate proxy, SSL-inspection appliance) intercepting and returning its own error status.","commonSituations":"Homebrew API or GitHub Pages incidents (check status); corporate proxies blocking the domain with 403; misconfigured egress gateways returning 5xx; transient upstream hiccups during a deploy of the static API.","solutions":["Check the Homebrew/GitHub Pages status and retry later for 5xx — the API is regenerated daily and outages are usually brief.","Verify with curl -I what status the URL returns and whether a proxy is injecting the error.","For 403, whitelist formulae.brew.sh in the proxy/firewall or exempt the domain from TLS inspection.","Wrap calls in retry-with-backoff for transient 5xx."],"exampleFix":"// before\nconst data = await brewFetch(url, 'formula info'); // 503 during outage -> throws\n// after\nlet data;\nfor (let attempt = 1; attempt <= 3; attempt++) {\n  try { data = await brewFetch(url, 'formula info'); break; }\n  catch (err) {\n    if (/HTTP 5\\d\\d/.test(err.message) && attempt < 3) { await sleep(2 ** attempt * 1000); continue; }\n    throw err;\n  }\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const data = await brewFetch(url, label);\n} catch (err) {\n  if (err instanceof CommandExecutionError && /HTTP \\d{3}/.test(err.message) && !/HTTP (404|429)/.test(err.message)) {\n    // 5xx/other: transient or upstream — retry with backoff or degrade gracefully\n    return getCachedOrEmpty(label);\n  }\n  throw err;\n}","preventionTips":["Subscribe to Homebrew/GitHub Pages status pages for outage awareness.","Wrap calls in retry-with-exponential-backoff for 5xx.","Check for corporate proxies/TLS inspection that inject non-API responses.","Degrade gracefully: serve stale cached data when the API is down."],"tags":["http-error","server-error","api"],"backgroundTag":"http-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}