chenhg5/cc-connect · error

gitee API returned HTTP %d

Error message

gitee API returned HTTP %d

What it means

fetchLatestStableFromGitee calls the Gitee releases API and requires exactly HTTP 200 (unlike the 2xx-range check elsewhere). Any other status — 404 for a missing repo, 403 rate limit, 5xx server error — yields this error naming the status code. The caller is the update checker looking for the latest stable release.

Source

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

		cachedLatestVersion.timestamp = time.Now()
		cachedLatestVersion.mu.Unlock()
	}()
}

// fetchLatestStableFromGitee 从Gitee获取最新稳定版本
func fetchLatestStableFromGitee() (*githubRelease, error) {
	client := &http.Client{Timeout: 3 * time.Second}
	req, _ := http.NewRequest("GET", giteeAPI, nil)
	req.Header.Set("Accept", "application/json")

	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

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

	var release githubRelease
	if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
		return nil, err
	}
	// Gitee的latest通常就是稳定版,但检查Prerelease以防万一
	if release.Prerelease {
		return nil, nil
	}
	return &release, nil
}

// checkUpdateAsync 启动异步版本检查(不阻塞)
func checkUpdateAsync() {
	// dev版本不检查
	if version == "dev" || version == "" {
		return

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify the Gitee API URL (owner/repo) still resolves: curl -i the endpoint
  2. Retry later on 5xx or 403 rate-limit responses
  3. Provide an API token if rate-limited or repo is private
  4. Check whether the repo moved and update the hardcoded API path

Example fix

// before
if resp.StatusCode != 200 {
	return nil, fmt.Errorf("gitee API returned HTTP %d", resp.StatusCode)
}
// after
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
	return nil, fmt.Errorf("gitee API returned HTTP %d: %s", resp.StatusCode, resp.Status)
}
Defensive patterns

Strategy: retry

Validate before calling

resp, err := http.Get(giteeAPIURL)
if err == nil && resp.StatusCode != 200 {
	return fmt.Errorf("gitee endpoint unhealthy: %d", resp.StatusCode)
}

Type guard

func isOK(code int) bool { return code == 200 }

Try / catch

rel, err := fetchLatestStableFromGitee(url)
if err != nil {
	slog.Warn("update check failed, keeping current version", "err", err)
	return nil // non-fatal for update checks
}

Prevention

When it happens

Trigger: Gitee API response with StatusCode != 200: wrong owner/repo path in the API URL, unauthenticated 403 from rate limiting, 404 after repo rename, transient 502/503.

Common situations: Repo renamed or made private; Gitee API rate limits without a token; network middleware returning HTML error pages with non-200 codes; Gitee outage.

Related errors


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