{"record":{"id":"7fc16ba9154292fb","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/crates/utils.js","lineNumber":62,"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 crates.io is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `crates.io returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'crates.io rate-limits unauthenticated traffic; 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":44,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/crates/utils.js#L44-L73","documentation":"This is the catch-all HTTP status branch of cratesFetch: any non-OK response that is not 404 or 429 becomes `\"${label} returned HTTP ${resp.status}\"` as a CommandExecutionError. It covers server errors (5xx), redirects the client won't follow, 403, and other unexpected statuses.","triggerScenarios":"Any crates subcommand calling cratesFetch when crates.io returns a non-OK status other than 404/429 — e.g. 500 during a backend incident, 403 from a firewall/CDN block, 502/503 from a proxy.","commonSituations":"crates.io or its CDN having an outage; corporate proxy intercepting TLS and returning 403; API version/endpoint change after an upgrade of the adapter.","solutions":["Read the status code in the message: 5xx means server-side — wait and retry; 403 means blocked — check proxy/firewall.","Check https://status.rust-lang.org for a crates.io outage before debugging locally.","Test the same URL with `curl -i -H 'user-agent: ...'` to see whether the failure is client-side or service-side.","Confirm you're on an up-to-date adapter version in case the crates.io endpoint changed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await opencli.crates.info(name);\n} catch (err) {\n  const m = err.message.match(/HTTP (\\d{3})/);\n  if (m && m[1] >= 500) {\n    // transient server-side failure: retry later\n  } else if (m && m[1] === 403) {\n    // check proxy/firewall\n  }\n  throw err;\n}","preventionTips":["Check https://status.rust-lang.org before debugging local issues.","Verify proxies/VPN aren't intercepting crates.io traffic.","Retry 5xx failures with backoff instead of failing the whole batch.","Keep the adapter up to date in case endpoints change."],"tags":["http-error","crates-io","server-error","network"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}