chenhg5/cc-connect · error

HTTP GET %s: status %d

Error message

HTTP GET %s: status %d

What it means

fetchSkillPresetsFromURL throws this when the HTTP response completes but the status code is not 200 OK. It is a non-2xx guard: 404 for a moved presets file, 403 for blocked access, 5xx for server trouble — the status is embedded in the message along with the URL.

Source

Thrown at core/skill_presets.go:128

		return nil, fmt.Errorf("fetch skill presets: %w", err)
	}

	c.data = result
	c.fetchedAt = time.Now()
	return c.data, nil
}

func fetchSkillPresetsFromURL(url string, timeout time.Duration) (*SkillPresetsResponse, error) {
	slog.Debug("fetching skill presets", "url", url)
	client := &http.Client{Timeout: timeout}
	resp, err := client.Get(url)
	if err != nil {
		return nil, fmt.Errorf("HTTP GET %s: %w", url, err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("HTTP GET %s: status %d", url, resp.StatusCode)
	}

	body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
	if err != nil {
		return nil, fmt.Errorf("read body from %s: %w", url, err)
	}

	var result SkillPresetsResponse
	if err := json.Unmarshal(body, &result); err != nil {
		return nil, fmt.Errorf("parse JSON from %s: %w", url, err)
	}
	return &result, nil
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check the logged status code: 404 → update the URL to the current presets location; 403 → check auth/UA requirements; 5xx → retry later
  2. curl -I the URL to confirm the status outside the app
  3. Replace the dead source with a maintained mirror; with multiple sources configured, fetch succeeds if any one returns 200
  4. If the source requires a token, switch to a source URL that includes authorized access

Example fix

// before
url = "https://example.com/skills-presets-v1.json"   // 404
// after
url = "https://example.com/skills-presets-v2.json"   // verify: curl -I returns 200
Defensive patterns

Strategy: retry

Validate before calling

resp, err := http.Head(sourceURL)
if err == nil && resp.StatusCode != http.StatusOK {
    return fmt.Errorf("presets source unhealthy: %s returns %d", sourceURL, resp.StatusCode)
}

Try / catch

presets, err := fetchSkillPresetsFromURL(url, timeout)
if err != nil {
    var statusErr interface{ Error() string }
    if strings.Contains(err.Error(), "status ") { // e.g. "HTTP GET ...: status 404"
        slog.Warn("presets source returned non-200; trying next source", "url", url, "err", err)
    }
    _ = statusErr
}

Prevention

When it happens

Trigger: GETting a skill presets URL that returns 404 (file renamed/moved), 403 (rate limit, geo/UA block, missing auth), 301/302 that Go followed to a non-200 endpoint, or 5xx during a server incident.

Common situations: Preset source URL pinned to an old version path that no longer exists; CDN blocking the default Go User-Agent; mirror returning 503 under load.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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