{"record":{"id":"2936ff5d38fa44cc","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-2936ff","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"critical","filePath":"clis/flathub/utils.js","lineNumber":57,"sourceCode":"        throw new ArgumentError(\n            `flathub appId \"${value}\" is not a valid AppStream identifier`,\n            'AppStream IDs use reverse-DNS like \"org.mozilla.firefox\" — letters/digits/`._-` with at least one dot.',\n        );\n    }\n    return raw;\n}\n\nexport async function flathubFetch(url, label, init) {\n    let resp;\n    try {\n        resp = await fetch(url, {\n            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) {","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/flathub/utils.js#L39-L75","documentation":"flathubFetch wraps the fetch() call to flathub.org; when the network request itself rejects (DNS failure, connection refused/reset, TLS error, timeout), it throws CommandExecutionError '<label> request failed: <underlying message>'. The library wraps rather than propagating the raw fetch error so callers get a consistent, labelled command failure.","triggerScenarios":"Any adapter call while flathub.org is unreachable: no network connection, DNS resolution failure, offline machine, VPN/firewall/proxy blocking flathub.org, TLS interception, or Node fetch aborting on timeout.","commonSituations":"Working offline or on a captive-portal Wi-Fi; corporate proxy blocking the domain; DNS misconfiguration (/etc/resolv.conf, VPN split tunneling); transient flathub.org outage; IPv6-only breakage.","solutions":["Check network connectivity and that https://flathub.org is reachable (curl -I https://flathub.org)","Retry after a short wait — the failure is often transient","Check proxy/firewall/VPN settings and DNS resolution (nslookup flathub.org)","Inspect the underlying message in the error text to identify DNS vs TLS vs timeout and fix accordingly"],"exampleFix":"// before\nawait appInfo('org.mozilla.firefox'); // fails offline with no handling\n// after\ntry {\n  await appInfo('org.mozilla.firefox');\n} catch (err) {\n  if (/request failed/.test(err.message)) {\n    console.error('flathub.org unreachable — check your network/proxy');\n  } else throw err;\n}","handlingStrategy":"retry","validationCode":"// Pre-flight reachability check (optional)\nconst ok = await fetch('https://flathub.org/api/v2/search', { method: 'HEAD' })\n  .then(() => true)\n  .catch(() => false);\nif (!ok) throw new Error('flathub.org is unreachable from this network');","typeGuard":"null","tryCatchPattern":"async function fetchWithRetry(fn, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return await fn(); }\n    catch (err) {\n      const transient = err instanceof CommandExecutionError && /request failed/.test(err.message);\n      if (!transient || i === attempts - 1) throw err;\n      await new Promise((r) => setTimeout(r, 2 ** i * 500));\n    }\n  }\n}","preventionTips":["Check connectivity/proxy settings when the error message mentions 'request failed'","Retry transient network failures with exponential backoff","Verify DNS resolution of flathub.org in restricted environments (VPN, containers, CI)","Configure HTTP(S)_PROXY variables if behind a corporate proxy"],"tags":["network","http-client","fetch-error"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}