{"record":{"id":"38742c14a8d18268","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-38742c","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/npm/utils.js","lineNumber":66,"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 registry.npmjs.org / api.npmjs.org are reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `npm registry returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'npm throttles unauthenticated 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","sourceCodeStart":48,"sourceCodeEnd":77,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/npm/utils.js#L48-L77","documentation":"This is npmFetch's catch-all for any HTTP status that is not 404 or 429 but still not ok (resp.ok is false for status >= 400). The helper throws CommandExecutionError with the raw status code, since no specific remediation is known. It surfaces unexpected server-side conditions (5xx) or unusual client errors (401/403) that the registry API returns outside its normal contract.","triggerScenarios":"npmFetch receives a response with status >= 400 other than 404/429: registry 5xx outages or partial failures, 401/403 from an internal proxy or firewall intercepting the request, 405/406 from an incompatible endpoint, or 502/503/504 from a reverse proxy in front of the registry.","commonSituations":"Corporate proxies or DNS filters returning 403 for unknown hosts; npm registry incidents producing 5xx responses; misconfigured HTTP_PROXY/HTTPS_PROXY env vars routing requests through a broken proxy; hitting a mirror endpoint that doesn't support the requested route.","solutions":["Check the status code in the message: 5xx means a server-side problem — check https://status.npmjs.org and retry later","401/403 usually means a proxy or firewall is intercepting; inspect HTTP(S)_PROXY settings and corporate network policies","Retry the request after a short delay — many 5xx conditions are transient","If it persists, verify the URL manually with `curl -i <url>` to see the full response and any proxy-injected body"],"exampleFix":"// before\nconst data = await npmFetch(url, 'npm package');\n// after\ntry {\n  const data = await npmFetch(url, 'npm package');\n} catch (err) {\n  const m = /HTTP (\\d{3})/.exec(err.message);\n  if (m && Number(m[1]) >= 500) {\n    console.error('npm registry is having issues; retry later.');\n  }\n  throw err;\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  return await npmFetch(url, label);\n} catch (err) {\n  const m = /HTTP (\\d{3})/.exec(String(err.message));\n  const status = m ? Number(m[1]) : 0;\n  if (status >= 500 || status === 408) {\n    await sleep(1000);\n    return await npmFetch(url, label); // transient server error — retry once\n  }\n  if (status === 401 || status === 403) {\n    throw new Error('Proxy/firewall blocked the request; check HTTP(S)_PROXY and network policy.');\n  }\n  throw err;\n}","preventionTips":["Check HTTP(S)_PROXY/HTTPS_PROXY environment variables before running in corporate networks","Monitor https://status.npmjs.org during npm incidents","Distinguish 5xx (retry) from 4xx (fix request) in your retry logic","Test registry reachability with `curl -I https://registry.npmjs.org` when debugging"],"tags":["npm","http-error","server-error","registry"],"backgroundTag":"unexpected-http-status","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}