{"record":{"id":"add20808701302b2","repo":"chenhg5/cc-connect","slug":"gitee-api-returned-http-d","errorCode":null,"errorMessage":"gitee API returned HTTP %d","messagePattern":"gitee API returned HTTP (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/update.go","lineNumber":77,"sourceCode":"\t\tcachedLatestVersion.timestamp = time.Now()\n\t\tcachedLatestVersion.mu.Unlock()\n\t}()\n}\n\n// fetchLatestStableFromGitee 从Gitee获取最新稳定版本\nfunc fetchLatestStableFromGitee() (*githubRelease, error) {\n\tclient := &http.Client{Timeout: 3 * time.Second}\n\treq, _ := http.NewRequest(\"GET\", giteeAPI, nil)\n\treq.Header.Set(\"Accept\", \"application/json\")\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"gitee API returned HTTP %d\", resp.StatusCode)\n\t}\n\n\tvar release githubRelease\n\tif err := json.NewDecoder(resp.Body).Decode(&release); err != nil {\n\t\treturn nil, err\n\t}\n\t// Gitee的latest通常就是稳定版，但检查Prerelease以防万一\n\tif release.Prerelease {\n\t\treturn nil, nil\n\t}\n\treturn &release, nil\n}\n\n// checkUpdateAsync 启动异步版本检查（不阻塞）\nfunc checkUpdateAsync() {\n\t// dev版本不检查\n\tif version == \"dev\" || version == \"\" {\n\t\treturn","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/update.go#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"Repo renamed or made private; Gitee API rate limits without a token; network middleware returning HTML error pages with non-200 codes; Gitee outage.","solutions":["Verify the Gitee API URL (owner/repo) still resolves: curl -i the endpoint","Retry later on 5xx or 403 rate-limit responses","Provide an API token if rate-limited or repo is private","Check whether the repo moved and update the hardcoded API path"],"exampleFix":"// before\nif resp.StatusCode != 200 {\n\treturn nil, fmt.Errorf(\"gitee API returned HTTP %d\", resp.StatusCode)\n}\n// after\nif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\treturn nil, fmt.Errorf(\"gitee API returned HTTP %d: %s\", resp.StatusCode, resp.Status)\n}","handlingStrategy":"retry","validationCode":"resp, err := http.Get(giteeAPIURL)\nif err == nil && resp.StatusCode != 200 {\n\treturn fmt.Errorf(\"gitee endpoint unhealthy: %d\", resp.StatusCode)\n}","typeGuard":"func isOK(code int) bool { return code == 200 }","tryCatchPattern":"rel, err := fetchLatestStableFromGitee(url)\nif err != nil {\n\tslog.Warn(\"update check failed, keeping current version\", \"err\", err)\n\treturn nil // non-fatal for update checks\n}","preventionTips":["Cache last-known release so transient API failures don't break updates","Back off and retry on 403/5xx","Pin the API URL and update it when the repo moves","Send an API token to avoid rate limits"],"tags":["http","api","gitee","update"],"backgroundTag":"http-non-200-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}