{"record":{"id":"61269eca28414204","repo":"jackwener/OpenCLI","slug":"label-request-failed-err-message-err-61269e","errorCode":null,"errorMessage":"${label} request failed: ${err?.message ?? err}","messagePattern":"(.+?) request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/nuget/utils.js","lineNumber":54,"sourceCode":"export function requirePackageId(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) throw new ArgumentError('nuget package id is required (e.g. \"Newtonsoft.Json\")');\n    if (!PACKAGE_ID_PATTERN.test(raw)) {\n        throw new ArgumentError(\n            `nuget package id \"${value}\" is not a valid NuGet identifier`,\n            'NuGet IDs are 1-100 chars: letters/digits/`.`/`_`/`-`, starting with letter or digit.',\n        );\n    }\n    return raw;\n}\n\nexport async function nugetFetch(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.nuget.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `NuGet 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    let body;\n    try {\n        body = await resp.json();\n    }\n    catch (err) {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/nuget/utils.js#L36-L72","documentation":"This CommandExecutionError wraps a network-level failure inside nugetFetch in clis/nuget/utils.js: the fetch() call to a NuGet endpoint rejected (DNS failure, connection refused, TLS error, offline) so no HTTP response exists. The message embeds the underlying error text and hints that api.nuget.org must be reachable. It is not an HTTP status error — the request never completed.","triggerScenarios":"Any nuget command (search/body/leaf paths that call nugetFetch) run while offline, behind a blocking firewall/proxy, with DNS failure for azuresearch-usnc.nuget.org or api.nuget.org, or with a TLS/certificate problem.","commonSituations":"Corporate proxies requiring custom CA certs not trusted by Node; VPN or captive-portal networks blocking the endpoint; CI runners without egress; typo'd proxy env vars breaking outbound fetch.","solutions":["Verify network connectivity: curl -I https://api.nuget.org/v3/index.json","Check proxy configuration (HTTPS_PROXY/HTTP_PROXY) and that the proxy allows nuget.org","Install/trust the corporate CA for Node (NODE_EXTRA_CA_CERTS) if TLS interception is in play","Retry after transient network issues; the error is usually environmental, not a code bug"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight reachability check\nconst ok = await fetch('https://api.nuget.org/v3/index.json', { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!ok) throw new Error('nuget.org unreachable from this network');","typeGuard":"null","tryCatchPattern":"try {\n  const data = await nugetFetch(url, 'search');\n} catch (e) {\n  if (e instanceof CommandExecutionError && e.message.includes('request failed')) {\n    await sleep(1000);\n    return nugetFetch(url, 'search'); // retry transient network failure\n  }\n  throw e;\n}","preventionTips":["Check proxy env vars (HTTPS_PROXY) and NODE_EXTRA_CA_CERTS in corporate networks","Add retry with exponential backoff for transient network errors","Preflight connectivity in CI before running bulk nuget jobs","Handle offline mode explicitly in scripts"],"tags":["network","fetch","connectivity","nuget"],"backgroundTag":"connection-refused","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}