chenhg5/cc-connect · error

too many redirects

Error message

too many redirects

What it means

A sentinel returned by the HTTP client's CheckRedirect hook in downloadToTemp: the release download URL redirected more than 10 times. It fires on redirect loops (misconfigured release mirrors or GitHub URL weirdness); the client aborts the download.

Source

Thrown at cmd/cc-connect/update.go:395

		if _, err := io.Copy(tmp, rc); err != nil {
			tmp.Close()
			rc.Close()
			os.Remove(tmp.Name())
			return "", fmt.Errorf("extract: %w", err)
		}
		rc.Close()
		tmp.Close()
		return tmp.Name(), nil
	}
	return "", fmt.Errorf("binary not found in archive")
}

func downloadToTemp(url string) (string, error) {
	client := &http.Client{
		Timeout: 5 * time.Minute,
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			if len(via) >= 10 {
				return fmt.Errorf("too many redirects")
			}
			return nil
		},
	}

	resp, err := client.Get(url)
	if err != nil {
		return "", fmt.Errorf("download: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return "", fmt.Errorf("download returned HTTP %d", resp.StatusCode)
	}

	tmp, err := os.CreateTemp("", "cc-connect-update-*")
	if err != nil {
		return "", err

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Retry later — transient redirect loops on CDN edges resolve themselves
  2. Verify the release URL/asset still exists on the releases page
  3. If persistent, download manually and replace the binary
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at cmd/cc-connect/update.go:395 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/b083fe8c0b0e1b57. Report an issue: GitHub.