{"record":{"id":"dfe734c150b33e17","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-dfe734","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/flathub/utils.js","lineNumber":69,"sourceCode":"            method: init?.method ?? 'GET',\n            headers: { 'user-agent': UA, accept: 'application/json', ...(init?.headers ?? {}) },\n            body: init?.body,\n        });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that flathub.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `Flathub 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) {\n        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);\n    }\n    return body;\n}\n\nexport function joinList(value, max = 10) {\n    if (!Array.isArray(value)) return '';\n    const items = value.filter((v) => typeof v === 'string' && v.trim());\n    if (items.length === 0) return '';\n    if (items.length > max) return [...items.slice(0, max), `(+${items.length - max})`].join(', ');\n    return items.join(', ');\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/flathub/utils.js#L51-L87","documentation":"flathubFetch throws CommandExecutionError '<label> returned HTTP <status>' for any non-OK response that is not specifically 404 or 429 (e.g. 500, 502, 503, 403). It signals an unexpected server-side or access problem with the Flathub API, with the status code embedded for diagnosis.","triggerScenarios":"Flathub returning 5xx during an outage or maintenance; 403 from a WAF/CDN blocking the client's IP or user-agent; gateway errors (502/504) from Cloudflare in front of flathub.org; unexpected API-side errors on a valid request.","commonSituations":"Calling the API during a Flathub outage or deploy; corporate proxies/CDN rules rejecting requests; shared-IP blocking; brief upstream instability causing intermittent 5xx.","solutions":["Check https://status.flathub.org or try the URL in a browser to see if Flathub is down","Retry with backoff — 5xx errors are often transient","Check for 403-specific causes: proxy/VPN IP blocked, or custom user-agent rejected — try from another network","If persistent, report/inspect the failing URL and status; adjust requests to match the current v2 API"],"exampleFix":"// before\nconst info = await appInfo(id); // crashes on transient 502\n// after\nlet info;\nfor (let attempt = 0; attempt < 3; attempt++) {\n  try { info = await appInfo(id); break; }\n  catch (err) {\n    if (!/HTTP 5\\d\\d/.test(err.message) || attempt === 2) throw err;\n    await new Promise((r) => setTimeout(r, 2 ** attempt * 500));\n  }\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const info = await appInfo(appId);\n} catch (err) {\n  const m = err.message.match(/HTTP (\\d{3})/);\n  if (m && Number(m[1]) >= 500) {\n    console.error('Flathub server error — retry later or check status.flathub.org');\n  } else throw err;\n}","preventionTips":["Check Flathub status before assuming your code is at fault on persistent 5xx","Build retry-with-backoff around all flathub API calls for 5xx resilience","Retry from a different network if you suspect IP/CDN blocking (403)","Keep the adapter updated in case the API moves away from /api/v2"],"tags":["http-error","server-error","http-api"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}