{"record":{"id":"abad3fb80cd141f6","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-abad3f","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/osv/utils.js","lineNumber":115,"sourceCode":"export async function osvGet(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 api.osv.dev is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `OSV.dev 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    return readJson(resp, label);\n}\n\nexport async function osvPost(url, payload, label) {\n    let resp;\n    try {\n        resp = await fetch(url, {\n            method: 'POST',\n            headers: { 'user-agent': UA, accept: 'application/json', 'content-type': 'application/json' },\n            body: JSON.stringify(payload),\n        });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that api.osv.dev is reachable from this network.',\n        );","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/osv/utils.js#L97-L133","documentation":"Generic catch-all for any non-ok HTTP status from api.osv.dev that isn't 404 or 429 (e.g. 500, 502, 503). Thrown as a CommandExecutionError with the raw status code and no remediation hint, since the failure is server-side or unexpected.","triggerScenarios":"osvGet (called by `vuln`) received a response whose status was neither 404 nor 429 and not resp.ok — for example a 5xx from OSV.dev infrastructure or an unexpected 3xx/4xx like 400 or 403.","commonSituations":"OSV.dev having a temporary outage; a proxy/firewall returning 403 or 502; sending a request shape OSV rejects with 400; corporate proxies MITM-ing TLS and returning gateway errors.","solutions":["Retry after a short delay — 5xx statuses are usually transient on OSV.dev","Log/handle the status code: 4xx indicates a bad request (fix the ID/URL), 5xx indicates a server problem","Check whether a corporate proxy or firewall is intercepting api.osv.dev traffic","Check OSV.dev status or its status page / GitHub for ongoing incidents"],"exampleFix":"// before\ntry { const v = await osvGet(url, label); } catch (e) { throw e; }\n// after\ntry { return await osvGet(url, label); }\ncatch (e) {\n  if (/HTTP 5\\d\\d/.test(e.message)) return retryWithBackoff(() => osvGet(url, label));\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const healthy = await fetch('https://api.osv.dev/v1/query', { method: 'HEAD' }).then(r => r.ok).catch(() => false); // pre-check service availability","typeGuard":"function isServerError(err) { return err instanceof Error && /HTTP 5\\d\\d/.test(err.message); }","tryCatchPattern":"try {\n  return await vuln(id);\n} catch (e) {\n  if (isServerError(e)) return retryWithBackoff(() => vuln(id), { retries: 3 });\n  throw e;\n}","preventionTips":["Distinguish 4xx (fix your request) from 5xx (retry later) in catch handlers","Check OSV.dev incident reports when 5xx errors cluster","Test through curl to rule out corporate proxy interference","Log the HTTP status embedded in the message for triage"],"tags":["http-error","network","osv"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}