chenhg5/cc-connect · error

no release found

Error message

no release found

What it means

fetchLatestStableRelease discovers the latest stable version purely from the Location header of a 302 redirect (redirects are disabled). This error means the redirect response carried no Location header, so the latest tag could not be determined.

Solutions

  1. Confirm the repo has at least one published release (a 404 from /releases/latest means zero releases)
  2. Bypass any intercepting proxy that may strip Location headers (test with curl -v and look for the 302 + Location line)
  3. Fall back to the /releases list endpoint (fetchLatestPreRelease path) which returns tags in the JSON body instead of headers
  4. Check repo visibility/token — a private repo without credentials yields no redirect

Example fix

// before
loc := resp2.Header.Get("Location")
if loc == "" {
    return nil, fmt.Errorf("no release found")
}
// after
loc := resp2.Header.Get("Location")
if loc == "" {
    return nil, fmt.Errorf("no release found (HTTP %d, no Location header)", resp2.StatusCode)
}
Defensive patterns

Strategy: fallback

Validate before calling

// check the latest-release URL returns a 302 with Location before parsing:
client := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
resp, err := client.Get("https://github.com/<owner>/<repo>/releases/latest")
if err == nil && resp.StatusCode == 404 {
    return errors.New("repo has no latest release (404)")
}

Try / catch

// Go: fall back to the releases list endpoint when the redirect probe fails
rel, err := fetchLatestStableRelease()
if err != nil {
    if strings.Contains(err.Error(), "no release found") {
        rel, err = fetchLatestPreRelease() // JSON body carries the tag
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: resp2.Header.Get("Location") is "": the server answered without a redirect (e.g. 200 page or 404 instead of 302), typically because /releases/latest has nothing to redirect to.

Common situations: Repository has no published releases (GitHub returns 404 without Location); a transparent proxy strips or rewrites the 302; repo is private and returns 404 without credentials; GitHub endpoint behavior differs from expected.

Related errors


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

Appendix: source

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

	}

	// Fallback: follow redirect from /releases/latest to extract tag
	latestURL := "https://github.com/" + githubRepo + "/releases/latest"
	noRedirect := &http.Client{
		Timeout: 15 * time.Second,
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return http.ErrUseLastResponse
		},
	}
	resp2, err := noRedirect.Get(latestURL)
	if err != nil {
		return nil, fmt.Errorf("request failed: %w", err)
	}
	defer resp2.Body.Close()

	loc := resp2.Header.Get("Location")
	if loc == "" {
		return nil, fmt.Errorf("no release found")
	}
	parts := strings.Split(loc, "/tag/")
	if len(parts) != 2 {
		return nil, fmt.Errorf("unexpected redirect: %s", loc)
	}
	return &githubRelease{TagName: parts[1], HTMLURL: loc}, nil
}

func binaryAssetName(tag string) string {
	goos := runtime.GOOS
	goarch := runtime.GOARCH
	name := fmt.Sprintf("cc-connect-%s-%s-%s", tag, goos, goarch)
	if goos == "windows" {
		name += ".exe"
	}
	return name
}

View on GitHub (pinned to 4000b2338a)