{"record":{"id":"d0592e85114c846f","repo":"chenhg5/cc-connect","slug":"http-get-s-status-d","errorCode":null,"errorMessage":"HTTP GET %s: status %d","messagePattern":"HTTP GET (.+?): status (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/provider_presets.go","lineNumber":145,"sourceCode":"\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)\n\t}\n\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read body from %s: %w\", url, err)\n\t}\n\n\tvar result ProviderPresetsResponse\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse JSON from %s: %w\", url, err)\n\t}\n\treturn &result, nil\n}\n","sourceCodeStart":127,"sourceCodeEnd":159,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/provider_presets.go#L127-L159","documentation":"`fetchPresetsFromURL` requires HTTP 200; any other status (404, 403, 500, etc.) aborts with `HTTP GET <url>: status <code>`. The request reached the server but the server rejected it or failed internally.","triggerScenarios":"Calling fetchPresetsFromURL against a URL whose response `resp.StatusCode != http.StatusOK` — e.g. the presets file was moved (404), the host requires auth (401/403), or the server is erroring (5xx).","commonSituations":"Upstream repository restructured so the presets JSON path changed; GitHub raw URL pointing at a private repo; CDN returning 502/503 during an outage; rate-limiting (429).","solutions":["Open the URL in a browser/curl and read the returned status code to identify the cause.","Update the configured presets source URL if the resource moved (404).","Add authentication or switch to a public mirror if you get 401/403.","Retry later or add a retry with backoff for transient 5xx/429 responses."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check (optional, racy but catches obvious 404s):\nresp, err := http.Head(presetsURL)\nif err == nil && resp.StatusCode != http.StatusOK { /* fix URL or warn */ }","typeGuard":null,"tryCatchPattern":"if resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"unexpected status %d from %s\", resp.StatusCode, url) // log and fall back to cache\n}","preventionTips":["Pin the presets source URL and update it when the upstream moves.","Alert on 4xx/5xx from the presets host.","Add retry-with-backoff for 429/5xx and fail fast (with cache fallback) on 4xx."],"tags":["http","status-code","network","go"],"backgroundTag":"http-error-response","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"}