chenhg5/cc-connect · error

fetch presets: %w

Error message

fetch presets: %w

What it means

The provider presets cache fetcher tried all configured preset sources and every one failed. Because there was no previously cached result (`c.data == nil`), it cannot fall back to stale data and instead returns a wrapped aggregate error via `fmt.Errorf("fetch presets: %w", err)`. It signals that provider preset data (e.g. model/provider lists shown in the UI) is completely unavailable, not just stale.

Source

Thrown at core/provider_presets.go:127

		return c.data, nil
	}

	primaryURL := c.url
	if primaryURL == "" {
		primaryURL = defaultPresetsURL
	}

	result, err := fetchPresetsFromURL(primaryURL, presetsHTTPTimeout)
	if err != nil {
		slog.Warn("primary presets fetch failed, trying fallback", "url", primaryURL, "error", err)
		result, err = fetchPresetsFromURL(fallbackPresetsURL, presetsFallbackHTTPTimeout)
	}
	if err != nil {
		if c.data != nil {
			slog.Warn("all presets sources failed, using stale cache", "error", err)
			return c.data, nil
		}
		return nil, fmt.Errorf("fetch presets: %w", err)
	}

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

func fetchPresetsFromURL(url string, timeout time.Duration) (*ProviderPresetsResponse, error) {
	slog.Debug("fetching provider 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)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Verify network connectivity to the presets source URL (curl the URL configured as the presets source).
  2. Fix the presets source URL in config.toml if it is wrong or unreachable.
  3. Configure a local/alternative presets source URL that is reachable from the host.
  4. If offline operation is expected, accept degraded behavior or pre-populate the cache by running once with network access.

Example fix

// before
data, err := cache.Fetch(ctx)
if err != nil { return err }

// after
data, err := cache.Fetch(ctx)
if err != nil {
    slog.Warn("provider presets unavailable, using built-in defaults", "error", err)
    data = defaultPresets
}
Defensive patterns

Strategy: fallback

Validate before calling

u, err := url.Parse(presetsSourceURL)
if err != nil || u.Host == "" { return fmt.Errorf("bad presets source %q", presetsSourceURL) }
// optionally: ping the URL once at startup before relying on it

Try / catch

data, err := cache.Fetch(ctx)
if err != nil {
    slog.Warn("presets unavailable, using defaults", "error", err)
    data = defaultPresets
}

Prevention

When it happens

Trigger: Calling the exported fetch path on the presets cache when (a) every source URL failed to fetch (network down, DNS failure, non-200 responses) AND (b) no successful fetch ever happened before, so `c.data` is nil.

Common situations: Running cc-connect offline or behind a corporate proxy that blocks the presets URL; misconfigured presets source URL in config; DNS resolution failure on a fresh install before the first successful fetch populated the cache.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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