{"record":{"id":"cdf276d031757db5","repo":"google-gemini/gemini-cli","slug":"download-failed-http-response-status-respons","errorCode":null,"errorMessage":"Download failed: HTTP ${response.status} ${response.statusText}","messagePattern":"Download failed: HTTP (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/gemma/setup.ts","lineNumber":79,"sourceCode":"    const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);\n    const pctStr = (pct * 100).toFixed(0).padStart(3);\n    process.stderr.write(\n      `\\r  [${bar}] ${pctStr}% ${formatBytes(downloaded)} / ${formatBytes(total)}`,\n    );\n  } else {\n    process.stderr.write(`\\r  Downloaded ${formatBytes(downloaded)}`);\n  }\n}\n\nasync function downloadFile(url: string, destPath: string): Promise<void> {\n  const tmpPath = destPath + '.downloading';\n  if (fs.existsSync(tmpPath)) {\n    fs.unlinkSync(tmpPath);\n  }\n\n  const response = await fetch(url, { redirect: 'follow' });\n  if (!response.ok) {\n    throw new Error(\n      `Download failed: HTTP ${response.status} ${response.statusText}`,\n    );\n  }\n  if (!response.body) {\n    throw new Error('Download failed: No response body');\n  }\n\n  const contentLength = response.headers.get('content-length');\n  const totalBytes = contentLength ? parseInt(contentLength, 10) : null;\n  let downloadedBytes = 0;\n\n  const fileStream = fs.createWriteStream(tmpPath);\n  const reader = response.body.getReader();\n\n  try {\n    for (;;) {\n      const { done, value } = await reader.read();\n      if (done) break;","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/commands/gemma/setup.ts#L61-L97","documentation":"During downloadFile() (used to fetch the LiteRT-LM binary for Gemma local model routing), if the HTTP response from fetch() has a non-2xx status, the error includes the status code and status text. This surfaces server-side failures (404, 403, 500, etc.) with actionable diagnostic information rather than a generic download failure.","triggerScenarios":"The binary download URL returns a 404 (binary not published for the detected platform), 403 (access forbidden), 500/502/503 (server error or CDN outage), or any other non-OK HTTP status.","commonSituations":"The LiteRT-LM binary hasn't been released for the user's platform/arch yet; network proxy returning an error page; CDN or hosting server outage; URL format changed in a new release; redirect chain ends at an error page.","solutions":["Check the HTTP status: 404 likely means the platform binary isn't available — verify platform support in constants.ts.","Verify network connectivity and proxy/firewall settings.","Retry later if it's a transient server-side issue (5xx).","For 403, check if the download requires authentication or has region restrictions."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function isDownloadUrlReachable(url: string): Promise<boolean> {\n  try {\n    const resp = await fetch(url, { method: 'HEAD' });\n    return resp.ok;\n  } catch {\n    return false;\n  }\n}\n\n// Before setup:\nif (!(await isDownloadUrlReachable(binaryUrl))) {\n  console.error('Binary download URL is not reachable.');\n}","typeGuard":null,"tryCatchPattern":"async function downloadWithRetry(url: string, dest: string, maxRetries = 3): Promise<void> {\n  for (let attempt = 1; attempt <= maxRetries; attempt++) {\n    try {\n      await downloadFile(url, dest);\n      return;\n    } catch (e) {\n      if (e instanceof Error && e.message.includes('HTTP 5') && attempt < maxRetries) {\n        await new Promise((r) => setTimeout(r, 1000 * attempt));\n        continue;\n      }\n      throw e;\n    }\n  }\n}","preventionTips":["Verify the platform is supported (check detectPlatform() and PLATFORM_BINARY_SHA256 in constants.ts).","Check network connectivity and proxy settings before running setup.","Retry on transient 5xx errors; do not retry on 404 (binary not published for your platform).","Use --force to re-download if a previous attempt left a corrupted partial file."],"tags":["network","download","gemma","http","binary"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}