{"record":{"id":"8e686465f9ae2bb7","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-8e6864","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":77,"sourceCode":"    if (artifactId.length > 200 || !COORD_TOKEN.test(artifactId)) {\n        throw new ArgumentError(\n            `maven artifactId \"${artifactId}\" is not a valid token`,\n            'Use letters / digits / \"_-.\" (max 200 chars), starting with a letter or digit.',\n        );\n    }\n    if (version != null && version.length > 200) {\n        throw new ArgumentError(`maven version \"${version}\" is too long (max 200 chars).`);\n    }\n    return { groupId, artifactId, version: version ?? null };\n}\n\nexport async function mavenFetch(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 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 {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L59-L95","documentation":"mavenFetch() wraps its fetch() call; if the network request itself throws (DNS failure, connection refused/reset, TLS error, offline), the error is rethrown as a CommandExecutionError with the label and the underlying message, advising that search.maven.org must be reachable.","triggerScenarios":"Any maven lookup while the network cannot reach search.maven.org: no internet, DNS outage, corporate proxy/firewall blocking the host, TLS interception, or Node fetch failing to resolve the hostname.","commonSituations":"Running in CI sandboxes without egress; VPN or proxy misconfiguration; DNS misconfigured in containers; the host being blocked by a corporate allowlist; transient network flap.","solutions":["Verify network connectivity (e.g. curl https://search.maven.org/solrsearch/select?q=guava).","Check DNS resolution for search.maven.org.","Configure proxy environment variables (HTTPS_PROXY) if behind a corporate proxy.","Retry after a moment if it was a transient network error; add retry with backoff around the call."],"exampleFix":"// before\nconst data = await mavenFetch(url, 'search');\n// after\ntry {\n  const data = await mavenFetch(url, 'search');\n} catch (err) {\n  if (/request failed/.test(String(err))) await sleep(1000); // retry transient network\n  throw err;\n}","handlingStrategy":"retry","validationCode":"const reachable = await fetch('https://search.maven.org/solrsearch/select?q=a:guava&rows=1')\n  .then(() => true).catch(() => false);\nif (!reachable) throw new Error('search.maven.org is not reachable');","typeGuard":"null","tryCatchPattern":"try {\n  return await mavenFetch(url, 'search');\n} catch (err) {\n  if (/request failed/.test(String(err.message))) {\n    await sleep(backoff(attempt)); // retry transient network errors\n    return mavenFetch(url, 'search');\n  }\n  throw err;\n}","preventionTips":["Check egress/firewall rules allow HTTPS to search.maven.org, especially in CI.","Set HTTPS_PROXY correctly in corporate environments.","Monitor DNS in containers/VPNs.","Wrap network calls in retry-with-backoff from the start."],"tags":["network","fetch","command-execution-error","maven"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}