{"record":{"id":"871132e1b6362041","repo":"coreybutler/nvm-windows","slug":"error-received-status-code-d","errorCode":null,"errorMessage":"error: received status code %d","messagePattern":"error: received status code (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upgrade/upgrade.go","lineNumber":728,"sourceCode":"\t}\n\n\tclient := &http.Client{}\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treq.Header.Set(\"User-Agent\", \"nvm-windows\")\n\treq.Header.Set(\"Cache-Control\", \"no-cache\")\n\treq.Header.Set(\"Pragma\", \"no-cache\")\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn []byte{}, fmt.Errorf(\"error: received status code %d\", resp.StatusCode)\n\t}\n\n\treturn io.ReadAll(resp.Body)\n}\n\nfunc checkForUpdate(url string) (*Update, error) {\n\tu := Update{Assets: []string{}, Warnings: []string{}, VersionWarnings: []string{}}\n\tr := Release{}\n\n\t// Make the HTTP GET request\n\tutility.DebugLogf(\"checking for updates at %s\", url)\n\tbody, err := get(url, false)\n\tif err != nil {\n\t\treturn &u, fmt.Errorf(\"error: reading response body: %v\", err)\n\t}\n\n\t// Parse JSON into the struct\n\tutility.DebugLogf(\"Received:\\n%s\", string(body))","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/upgrade/upgrade.go#L710-L746","documentation":"The get() helper behind every upgrade HTTP request returns this error when the server responds with any status other than 200 OK. It discards the body and reports only the code, so '403', '404', or '429' all surface through this one message. It is the shared failure point for version checks, zip downloads, checksum downloads, and asset downloads.","triggerScenarios":"GitHub API rate limiting (429/403) when the update-check URL hits api.github.com too often from one IP; 404 when a release asset or checksum file is missing; 403 from a proxy or region-blocked CDN; 5xx during GitHub incidents; redirect chains ending somewhere non-200.","commonSituations":"CI machines sharing an egress IP exhausting the unauthenticated GitHub API quota; release asset renamed by maintainers; corporate proxies returning 403 challenge pages; users in regions where GitHub serves intermittently.","solutions":["Map the status code: 403/429 → rate limit or proxy block, 404 → missing asset, 5xx → upstream incident; retry later for 429/5xx.","For GitHub API rate limits, wait for the quota window or supply a token-bearing endpoint where supported.","Verify the exact URL with curl -I to see headers (x-ratelimit-remaining on api.github.com).","If a proxy returns 403, bypass it for the release host or authenticate to it."],"exampleFix":"// before\nif resp.StatusCode != http.StatusOK {\n    return []byte{}, fmt.Errorf(\"error: received status code %d\", resp.StatusCode)\n}\n\n// after: include the URL and a body snippet to make diagnosis immediate\nif resp.StatusCode != http.StatusOK {\n    snippet, _ := io.ReadAll(io.LimitReader(resp.Body, 200))\n    return nil, fmt.Errorf(\"error: GET %s returned status %d: %s\", req.URL, resp.StatusCode, snippet)\n}","handlingStrategy":"retry","validationCode":"// Check reachability and rate-limit headroom before the request\nresp, err := http.Head(url)\nif err == nil {\n    if remain := resp.Header.Get(\"X-RateLimit-Remaining\"); remain == \"0\" {\n        return fmt.Errorf(\"rate limited; retry after \" + resp.Header.Get(\"X-RateLimit-Reset\"))\n    }\n}","typeGuard":null,"tryCatchPattern":"Switch on the numeric code: 429/5xx → backoff retry with honor for Retry-After; 403 → proxy/auth investigation; 404 → permanent, do not retry, surface the URL.","preventionTips":["Cache release-check results instead of hitting the API every command on shared egress IPs.","Monitor x-ratelimit-remaining on CI machines.","Bypass or authenticate through intercepting proxies."],"tags":["network","http","rate-limit","nvm-windows"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}