abiosoft/colima · error

unexpected status code: %d

Error message

unexpected status code: %d

What it means

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.

Source

Thrown at model/ramalama.go:50

	// Output format: "ramalama version 0.17.1"
	output = strings.TrimSpace(output)
	if version, ok := strings.CutPrefix(output, "ramalama version "); ok {
		return version
	}
	return ""
}

// getLatestRamalamaVersion fetches the latest release version from GitHub.
func getLatestRamalamaVersion() (string, error) {
	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Get(ramalamaReleasesURL)
	if err != nil {
		return "", fmt.Errorf("failed to fetch releases: %w", err)
	}
	defer func() { _ = resp.Body.Close() }()

	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("unexpected status code: %d", resp.StatusCode)
	}

	var release struct {
		TagName string `json:"tag_name"`
	}
	if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
		return "", fmt.Errorf("failed to decode response: %w", err)
	}

	// Tag might be "v0.17.1" or "0.17.1"
	version := strings.TrimPrefix(release.TagName, "v")
	return version, nil
}

// ramalamaModel represents a model from ramalama ls --json output.
type ramalamaModel struct {
	Name     string `json:"name"`
	Modified string `json:"modified"`

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Wait for the rate-limit window to reset (up to 1h) or make the request authenticated by exporting GH_TOKEN/GITHUB_TOKEN, then retry
  2. Inspect the actual status by fetching the releases URL manually (curl -I) and address what you see: proxy interference, 404, or outage
  3. Retry once after confirming general connectivity to api.github.com
  4. Skip or pin the update path when running offline so the latest-release lookup is not required

Example fix

// before
resp, err := client.Get(ramalamaReleasesURL)
if err != nil {
	return "", fmt.Errorf("failed to fetch releases: %w", err)
}

// after
req, _ := http.NewRequest(http.MethodGet, ramalamaReleasesURL, nil)
if tok := os.Getenv("GH_TOKEN"); tok != "" {
	req.Header.Set("Authorization", "Bearer "+tok)
}
resp, err := client.Do(req)
if err != nil {
	return "", fmt.Errorf("failed to fetch releases: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// cheap preflight before triggering an update check
func releasesAPIReachable(url string) bool {
	client := &http.Client{Timeout: 5 * time.Second}
	resp, err := client.Head(url)
	if err != nil {
		return false
	}
	defer func() { _ = resp.Body.Close() }()
	return resp.StatusCode >= 200 && resp.StatusCode < 300
}

Try / catch

// err returned from getLatestRamalamaVersion / GetSetupStatus
if strings.Contains(err.Error(), "unexpected status code: 403") {
	// rate limited: back off to the next hour window or authenticate, then retry
} else if strings.Contains(err.Error(), "unexpected status code: 5") {
	// server-side: retry with backoff
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/57d620cd0436efad. Report an issue: GitHub.