{"record":{"id":"40e34a84c3763052","repo":"chenhg5/cc-connect","slug":"fetch-presets-w","errorCode":null,"errorMessage":"fetch presets: %w","messagePattern":"fetch presets: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/provider_presets.go","lineNumber":127,"sourceCode":"\t\treturn c.data, nil\n\t}\n\n\tprimaryURL := c.url\n\tif primaryURL == \"\" {\n\t\tprimaryURL = defaultPresetsURL\n\t}\n\n\tresult, err := fetchPresetsFromURL(primaryURL, presetsHTTPTimeout)\n\tif err != nil {\n\t\tslog.Warn(\"primary presets fetch failed, trying fallback\", \"url\", primaryURL, \"error\", err)\n\t\tresult, err = fetchPresetsFromURL(fallbackPresetsURL, presetsFallbackHTTPTimeout)\n\t}\n\tif err != nil {\n\t\tif c.data != nil {\n\t\t\tslog.Warn(\"all presets sources failed, using stale cache\", \"error\", err)\n\t\t\treturn c.data, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"fetch presets: %w\", err)\n\t}\n\n\tc.data = result\n\tc.fetchedAt = time.Now()\n\treturn c.data, nil\n}\n\nfunc fetchPresetsFromURL(url string, timeout time.Duration) (*ProviderPresetsResponse, error) {\n\tslog.Debug(\"fetching provider presets\", \"url\", url)\n\tclient := &http.Client{Timeout: timeout}\n\tresp, err := client.Get(url)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HTTP GET %s: %w\", url, err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"HTTP GET %s: status %d\", url, resp.StatusCode)","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/provider_presets.go#L109-L145","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify network connectivity to the presets source URL (curl the URL configured as the presets source).","Fix the presets source URL in config.toml if it is wrong or unreachable.","Configure a local/alternative presets source URL that is reachable from the host.","If offline operation is expected, accept degraded behavior or pre-populate the cache by running once with network access."],"exampleFix":"// before\ndata, err := cache.Fetch(ctx)\nif err != nil { return err }\n\n// after\ndata, err := cache.Fetch(ctx)\nif err != nil {\n    slog.Warn(\"provider presets unavailable, using built-in defaults\", \"error\", err)\n    data = defaultPresets\n}","handlingStrategy":"fallback","validationCode":"u, err := url.Parse(presetsSourceURL)\nif err != nil || u.Host == \"\" { return fmt.Errorf(\"bad presets source %q\", presetsSourceURL) }\n// optionally: ping the URL once at startup before relying on it","typeGuard":null,"tryCatchPattern":"data, err := cache.Fetch(ctx)\nif err != nil {\n    slog.Warn(\"presets unavailable, using defaults\", \"error\", err)\n    data = defaultPresets\n}","preventionTips":["Monitor the presets source URL with a periodic health check.","Keep a built-in default preset list as a last-resort fallback.","Document the required network egress for deployments behind firewalls."],"tags":["network","http","cache","go"],"backgroundTag":"http-request-failed","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"}