{"record":{"id":"57d620cd0436efad","repo":"abiosoft/colima","slug":"unexpected-status-code-d","errorCode":null,"errorMessage":"unexpected status code: %d","messagePattern":"unexpected status code: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"model/ramalama.go","lineNumber":50,"sourceCode":"\t// Output format: \"ramalama version 0.17.1\"\n\toutput = strings.TrimSpace(output)\n\tif version, ok := strings.CutPrefix(output, \"ramalama version \"); ok {\n\t\treturn version\n\t}\n\treturn \"\"\n}\n\n// getLatestRamalamaVersion fetches the latest release version from GitHub.\nfunc getLatestRamalamaVersion() (string, error) {\n\tclient := &http.Client{Timeout: 10 * time.Second}\n\tresp, err := client.Get(ramalamaReleasesURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to fetch releases: %w\", err)\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)\n\t}\n\n\tvar release struct {\n\t\tTagName string `json:\"tag_name\"`\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(&release); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to decode response: %w\", err)\n\t}\n\n\t// Tag might be \"v0.17.1\" or \"0.17.1\"\n\tversion := strings.TrimPrefix(release.TagName, \"v\")\n\treturn version, nil\n}\n\n// ramalamaModel represents a model from ramalama ls --json output.\ntype ramalamaModel struct {\n\tName     string `json:\"name\"`\n\tModified string `json:\"modified\"`","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/model/ramalama.go#L32-L68","documentation":"Raised by getLatestRamalamaVersion (model/ramalama.go) when the HTTP GET to the GitHub releases endpoint for the latest ramalama release completes but returns any status other than 200; the numeric code is interpolated into the message. Callers wrap it into 'could not check for updates' (model/runner.go:401), so it is the root of update-check failures. Most often the embedded code is 403, GitHub's unauthenticated rate limit.","triggerScenarios":"client.Get(ramalamaReleasesURL) returns 403 after the 60 req/hr unauthenticated GitHub API quota is exhausted (typical on a shared CI egress IP), 404 if the release tag or URL moved, 502/503 during GitHub incidents, or a proxy/auth-portal status when a corporate proxy intercepts api.github.com.","commonSituations":"CI pipelines running colima model commands repeatedly from one IP; corporate HTTPS proxies rewriting responses; invoking the update check while GitHub is having an outage.","solutions":["Wait for the rate-limit window to reset (up to 1h) or make the request authenticated by exporting GH_TOKEN/GITHUB_TOKEN, then retry","Inspect the actual status by fetching the releases URL manually (curl -I) and address what you see: proxy interference, 404, or outage","Retry once after confirming general connectivity to api.github.com","Skip or pin the update path when running offline so the latest-release lookup is not required"],"exampleFix":"// before\nresp, err := client.Get(ramalamaReleasesURL)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"failed to fetch releases: %w\", err)\n}\n\n// after\nreq, _ := http.NewRequest(http.MethodGet, ramalamaReleasesURL, nil)\nif tok := os.Getenv(\"GH_TOKEN\"); tok != \"\" {\n\treq.Header.Set(\"Authorization\", \"Bearer \"+tok)\n}\nresp, err := client.Do(req)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"failed to fetch releases: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// cheap preflight before triggering an update check\nfunc releasesAPIReachable(url string) bool {\n\tclient := &http.Client{Timeout: 5 * time.Second}\n\tresp, err := client.Head(url)\n\tif err != nil {\n\t\treturn false\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\treturn resp.StatusCode >= 200 && resp.StatusCode < 300\n}","typeGuard":null,"tryCatchPattern":"// err returned from getLatestRamalamaVersion / GetSetupStatus\nif strings.Contains(err.Error(), \"unexpected status code: 403\") {\n\t// rate limited: back off to the next hour window or authenticate, then retry\n} else if strings.Contains(err.Error(), \"unexpected status code: 5\") {\n\t// server-side: retry with backoff\n}","preventionTips":["Authenticate GitHub API calls with a token when colima model runs in CI","Cache the last known latest version so repeated update checks do not re-hit the API","Rate-limit update checks to at most once per session"],"tags":["network","http","github-api","rate-limit","go"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}