{"record":{"id":"764e7facf416934e","repo":"jackwener/OpenCLI","slug":"label-returned-http-resp-status-764e7f","errorCode":null,"errorMessage":"${label} returned HTTP ${resp.status}","messagePattern":"(.+?) returned HTTP (.+?)","errorType":"http","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":92,"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 search.maven.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `Maven Central returned 404 for ${url}.`);\n    }\n    if (resp.status === 429) {\n        throw new CommandExecutionError(\n            `${label} returned HTTP 429 (rate limited)`,\n            'Maven Central throttles 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\n/** Convert epoch-ms (Maven Solr `timestamp`) to ISO-8601 UTC. Returns null for falsy/invalid. */\nexport function epochMsToIso(value) {\n    if (value == null) return null;\n    const n = typeof value === 'number' ? value : Number(value);\n    if (!Number.isFinite(n) || n <= 0) return null;\n    return new Date(n).toISOString().replace(/\\.\\d+Z$/, 'Z');\n}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L74-L110","documentation":"mavenFetch() throws a CommandExecutionError when the response status is not ok and is not the specifically handled 404/429 cases — i.e. any other HTTP error (5xx, 403, 400, etc.) from search.maven.org.","triggerScenarios":"Maven Central returning 5xx during outages/maintenance, 403 from WAF/CDN blocking, 400 from a malformed query string that reached the server, or gateway 502/503/504 from infrastructure.","commonSituations":"Building a Solr query with characters that need encoding (spaces, ampersands) producing 400; search.maven.org having an outage; a CDN/WAF blocking the client IP; timeouts surfaced as 5xx from a proxy.","solutions":["Check the status code in the message to pick a response (5xx = server side, retry later; 403 = check IP/proxy).","URL-encode query parameters (encodeURIComponent) before building the URL.","Check Maven Central status (status.maven.org / central.sonatype.com) for outages.","Retry with backoff for transient 5xx; otherwise fix the request URL."],"exampleFix":"// before\nconst url = `${MAVEN_BASE}?q=a:\"${name}\"`;\n// after\nconst url = `${MAVEN_BASE}?q=${encodeURIComponent(`a:\"${name}\"`)}&rows=5`;","handlingStrategy":"retry","validationCode":"const url = `${MAVEN_BASE}?q=${encodeURIComponent(query)}&rows=${rows}`;\nnew URL(url); // throws early if the URL is malformed","typeGuard":"null","tryCatchPattern":"try {\n  return await mavenFetch(url, 'search');\n} catch (err) {\n  const m = /HTTP (\\d{3})/.exec(err.message);\n  if (m && Number(m[1]) >= 500) {\n    await sleep(backoff(attempt));\n    return mavenFetch(url, 'search');\n  }\n  throw err;\n}","preventionTips":["URL-encode all query parameters (encodeURIComponent).","Retry 5xx with backoff; treat 4xx (except 404/429) as a request bug.","Watch search.maven.org/central.sonatype.com status during outages.","Check whether a proxy/WAF is blocking or rewriting requests."],"tags":["http-error","maven","command-execution-error","http-5xx"],"backgroundTag":"http-5xx-server-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}