{"record":{"id":"07f8f1b8d373f4cf","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-07f8f1","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/homebrew/utils.js","lineNumber":66,"sourceCode":"export function requireOneOf(value, allowed, label) {\n    const s = String(value ?? '').trim().toLowerCase();\n    if (!s) throw new ArgumentError(`homebrew ${label} is required`);\n    if (!allowed.includes(s)) {\n        throw new ArgumentError(\n            `homebrew ${label} \"${value}\" is not supported`,\n            `Allowed: ${allowed.join(', ')}.`,\n        );\n    }\n    return s;\n}\n\nexport async function brewFetch(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 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 {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/homebrew/utils.js#L48-L84","documentation":"brewFetch wraps all network calls to formulae.brew.sh. If fetch() itself rejects — DNS failure, connection refused, TLS error, offline machine — the library converts the raw TypeError into a CommandExecutionError with the original message and a hint to check network reachability of formulae.brew.sh. This distinguishes transport-level failures from HTTP error statuses.","triggerScenarios":"Calling any homebrew adapter function that ends in brewFetch (formula/cask info, popular analytics) while the network is down, DNS cannot resolve formulae.brew.sh, a corporate proxy/firewall blocks the host, or TLS interception breaks the handshake.","commonSituations":"CI runners without egress to GitHub Pages (the API is served from there); laptops on VPNs or captive-portal Wi-Fi; offline development; typo'd corporate proxy env vars breaking Node's fetch.","solutions":["Verify basic connectivity: curl https://formulae.brew.sh/api/formula/wget.json should return JSON.","Check proxy/VPN/firewall settings and set HTTPS_PROXY correctly if the network requires one.","Retry after confirming the network is back; the failure is usually transient (offline, captive portal).","If the host is permanently blocked, mirror the API JSON locally and point the adapter at the mirror."],"exampleFix":"// before\nconst data = await brewFetch(`${BREW_BASE}/formula/${token}.json`, 'formula info'); // throws offline\n// after\ntry {\n  const data = await brewFetch(`${BREW_BASE}/formula/${token}.json`, 'formula info');\n} catch (err) {\n  if (err instanceof CommandExecutionError && /request failed/.test(err.message)) {\n    // offline / DNS / proxy: alert or fall back to cached data\n  }\n  throw err;\n}","handlingStrategy":"retry","validationCode":"async function canReachBrewApi() {\n  try {\n    const r = await fetch('https://formulae.brew.sh/api/formula/wget.json', { method: 'HEAD' });\n    return r.ok || r.status === 404; // reachable either way\n  } catch { return false; }\n}\nif (!(await canReachBrewApi())) throw new Error('formulae.brew.sh unreachable — check network/proxy');","typeGuard":"null","tryCatchPattern":"try {\n  const data = await brewFetch(url, label);\n} catch (err) {\n  if (err instanceof CommandExecutionError && /request failed/.test(err.message)) {\n    await sleep(2000);\n    return brewFetch(url, label); // one retry after transient network failure\n  }\n  throw err;\n}","preventionTips":["Health-check formulae.brew.sh before bulk runs.","Configure HTTPS_PROXY/NO_PROXY correctly on CI and corporate networks.","Add automatic retry with backoff around network calls.","Avoid running brew lookups on networks known to block GitHub Pages."],"tags":["network","fetch-failed","connectivity"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}