{"record":{"id":"3fe4aa8fcc9ed8cb","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-3fe4aa","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/goproxy/utils.js","lineNumber":66,"sourceCode":"export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`goproxy ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`goproxy ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nasync function rawFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that proxy.golang.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404 || resp.status === 410) {\n        throw new EmptyResultError(label, `proxy.golang.org returned ${resp.status} 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 resp;\n}\n\nexport async function goproxyJson(url, label) {\n    const resp = await rawFetch(url, label);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/goproxy/utils.js#L48-L84","documentation":"rawFetch wraps the underlying fetch() failure in a CommandExecutionError at clis/goproxy/utils.js:66. This means the HTTP request to proxy.golang.org never completed — a network-level failure (DNS, TCP, TLS, proxy) rather than an HTTP error status, with the original error message appended.","triggerScenarios":"fetch() rejects: DNS resolution failure for proxy.golang.org, no internet/VPN down, corporate firewall blocking, TLS interception with an untrusted cert, or Node < 18 without global fetch bound in the runtime.","commonSituations":"Working offline; CI runners without network egress; restrictive corporate proxies; IPv6/DNS misconfiguration; NODE_OPTIONS/runtime where fetch is undefined so calling it throws TypeError captured here.","solutions":["Verify network reachability: `curl -I https://proxy.golang.org` from the same machine.","Check DNS (`nslookup proxy.golang.org`) and any HTTP(S)_PROXY environment variables; set them for the CLI if your network requires a proxy.","Restore internet/VPN access or run from a network that allows proxy.golang.org.","If running old Node (<18), upgrade so global fetch exists, or polyfill undici."],"exampleFix":"// before (CI, no egress)\nconst versions = await goproxyVersions(mod);\n// after — configure proxy / verify connectivity first\nawait dns.promises.resolve('proxy.golang.org');\nconst versions = await goproxyVersions(mod);","handlingStrategy":"retry","validationCode":"// Pre-flight connectivity check\ntry {\n  await fetch('https://proxy.golang.org', { method: 'HEAD' });\n} catch {\n  throw new Error('proxy.golang.org unreachable — check network/proxy settings');\n}","typeGuard":"null","tryCatchPattern":"try {\n  const data = await goproxyJson(url, label);\n} catch (err) {\n  if (err instanceof CommandExecutionError && /request failed/.test(err.message)) {\n    // network-level failure: retry with backoff or surface connectivity guidance\n    await new Promise(r => setTimeout(r, 2000));\n    return goproxyJson(url, label);\n  }\n  throw err;\n}","preventionTips":["Check HTTPS_PROXY/HTTP_PROXY env vars when behind a corporate network.","Run a curl preflight against proxy.golang.org in CI before bulk jobs.","Ensure Node ≥ 18 so global fetch is available.","Cache module/version lookups to minimise network dependency."],"tags":["network","http","fetch","goproxy"],"backgroundTag":"network-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}