google-gemini/gemini-cli · error · Error

Invalid response code downloading ${endpoint}: ${response.st

Error message

Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}

What it means

Thrown by downloadFiles() during /setup-github when the fetch to raw.githubusercontent.com returns a non-2xx status. The endpoint is built from REPO_DOWNLOAD_URL + the release tag + examples/workflows/<file>. A 404 means the tag/path is wrong; 403 typically means GitHub rate limiting.

Source

Thrown at packages/cli/src/ui/commands/setupGithubCommand.ts:139

  const downloads = [];
  for (const fileBasename of paths) {
    downloads.push(
      (async () => {
        const endpoint = `${REPO_DOWNLOAD_URL}/refs/tags/${releaseTag}/${SOURCE_DIR}/${fileBasename}`;
        const response = await fetch(endpoint, {
          method: 'GET',
          dispatcher: proxy ? new ProxyAgent(proxy) : undefined,
          /* eslint-disable @typescript-eslint/no-unsafe-type-assertion */
          signal: (
            AbortSignal as unknown as {
              any: (signals: AbortSignal[]) => AbortSignal;
            }
          ).any([AbortSignal.timeout(30_000), abortController.signal]),
          /* eslint-enable @typescript-eslint/no-unsafe-type-assertion */
        } as RequestInit);

        if (!response.ok) {
          throw new Error(
            `Invalid response code downloading ${endpoint}: ${response.status} - ${response.statusText}`,
          );
        }
        const body = response.body;
        if (!body) {
          throw new Error(
            `Empty body while downloading ${endpoint}: ${response.status} - ${response.statusText}`,
          );
        }

        const destination = path.resolve(
          targetDir,
          path.basename(fileBasename),
        );

        const fileStream = fs.createWriteStream(destination, {
          mode: 0o644, // -rw-r--r--, user(rw), group(r), other(r)
          flags: 'w', // write and overwrite

View on GitHub (pinned to 5024443c72)

Solutions

  1. Retry shortly after — transient 403s from raw.githubusercontent.com rate limits usually clear.
  2. Check network/proxy connectivity and the configured proxy (config.getProxy()) if one is set.
  3. Verify the latest release tag of google-github-actions/run-gemini-cli actually contains examples/workflows/<file>.
  4. If behind a proxy or offline, configure GEMINI_PROXY / the proxy setting or run from a network with access to GitHub.
Defensive patterns

Strategy: retry

Validate before calling

async function endpointReachable(endpoint: string, proxy?: string): Promise<boolean> {
  const res = await fetch(endpoint, { method: 'HEAD', dispatcher: proxy ? new ProxyAgent(proxy) : undefined, signal: AbortSignal.timeout(10_000) } as RequestInit);
  return res.ok || res.status === 200;
}

Type guard

function isHttpStatusError(e: unknown): boolean {
  return e instanceof Error && /Invalid response code downloading/.test(e.message);
}

Try / catch

for (let attempt = 1; attempt <= 3; attempt++) {
  try { await runSetupGithub(ctx); break; }
  catch (e) {
    if (e instanceof Error && /Invalid response code downloading/.test(e.message) && attempt < 3) continue;
    throw e;
  }
}

Prevention

When it happens

Trigger: fetch(endpoint) returns response.ok === false for a workflow file URL; common codes are 404 (release tag/path mismatch) or 403 (unauthenticated GitHub raw-content rate limit).

Common situations: getLatestGitHubRelease returned an unexpected/tag that lacks the examples/workflows files; GitHub raw content rate-limited the unauthenticated request; network/proxy returned an error page; the repo path structure changed in a newer release.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/c400b59f06529ca8. Report an issue: GitHub.