{"record":{"id":"5106a36983d540f9","repo":"google-gemini/gemini-cli","slug":"empty-body-while-downloading-endpoint-respon","errorCode":null,"errorMessage":"Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}","messagePattern":"Empty body while downloading (.+?): (.+?) - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/ui/commands/setupGithubCommand.ts","lineNumber":145,"sourceCode":"          method: 'GET',\n          dispatcher: proxy ? new ProxyAgent(proxy) : undefined,\n          /* eslint-disable @typescript-eslint/no-unsafe-type-assertion */\n          signal: (\n            AbortSignal as unknown as {\n              any: (signals: AbortSignal[]) => AbortSignal;\n            }\n          ).any([AbortSignal.timeout(30_000), abortController.signal]),\n          /* eslint-enable @typescript-eslint/no-unsafe-type-assertion */\n        } as RequestInit);\n\n        if (!response.ok) {\n          throw new Error(\n            `Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}`,\n          );\n        }\n        const body = response.body;\n        if (!body) {\n          throw new Error(\n            `Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}`,\n          );\n        }\n\n        const destination = path.resolve(\n          targetDir,\n          path.basename(fileBasename),\n        );\n\n        const fileStream = fs.createWriteStream(destination, {\n          mode: 0o644, // -rw-r--r--, user(rw), group(r), other(r)\n          flags: 'w', // write and overwrite\n          flush: true,\n        });\n\n        await body.pipeTo(Writable.toWeb(fileStream));\n      })(),\n    );","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/ui/commands/setupGithubCommand.ts#L127-L163","documentation":"Thrown when the download fetch returns response.ok === true but response.body is null/empty. This is an anomalous server/proxy response where a success status was sent without a readable body stream.","triggerScenarios":"fetch resolves with a 2xx status yet response.body is undefined/null, so there is nothing to pipe to the destination file.","commonSituations":"An intermediary proxy or CDN returned a success status with an empty body; a transient server anomaly; a redirect mishandled by the proxy such that the body is dropped.","solutions":["Retry the /setup-github command — empty-body anomalies are usually transient.","If a proxy is configured (config.getProxy()), verify it forwards bodies correctly or temporarily bypass it.","Retry when not rate-limited; confirm the endpoint is reachable directly."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function hasBody(endpoint: string, proxy?: string): Promise<boolean> {\n  const res = await fetch(endpoint, { dispatcher: proxy ? new ProxyAgent(proxy) : undefined, signal: AbortSignal.timeout(10_000) } as RequestInit);\n  return res.ok && !!res.body;\n}","typeGuard":"function isEmptyBodyError(e: unknown): boolean {\n  return e instanceof Error && /Empty body while downloading/.test(e.message);\n}","tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try { await runSetupGithub(ctx); break; }\n  catch (e) {\n    if (e instanceof Error && /Empty body while downloading/.test(e.message) && attempt < 3) continue;\n    throw e;\n  }\n}","preventionTips":["Retry empty-body anomalies; they are usually transient server/proxy events.","Verify the proxy forwards response bodies correctly or bypass it for raw.githubusercontent.com.","Run /setup-github from a network with direct GitHub access."],"tags":["network","github","download","http","setup-github"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}