{"record":{"id":"fcea4eab9cae5482","repo":"golang/go","slug":"reading-s-v-fcea4e","errorCode":null,"errorMessage":"reading %s: %v","messagePattern":"reading (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/web/api.go","lineNumber":95,"sourceCode":"\treturn e.Err\n}\n\n// GetBytes returns the body of the requested resource, or an error if the\n// response status was not http.StatusOK.\n//\n// GetBytes is a convenience wrapper around Get and Response.Err.\nfunc GetBytes(u *url.URL) ([]byte, error) {\n\tresp, err := Get(DefaultSecurity, u)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tif err := resp.Err(); err != nil {\n\t\treturn nil, err\n\t}\n\tb, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading %s: %v\", u.Redacted(), err)\n\t}\n\treturn b, nil\n}\n\ntype Response struct {\n\tURL        string // redacted\n\tStatus     string\n\tStatusCode int\n\tHeader     map[string][]string\n\tBody       io.ReadCloser // Either the original body or &errorDetail.\n\n\tfileErr     error\n\terrorDetail errorDetailBuffer\n}\n\n// Err returns an *HTTPError corresponding to the response r.\n// If the response r has StatusCode 200 or 0 (unset), Err returns nil.\n// Otherwise, Err may read from r.Body in order to extract relevant error detail.","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/web/api.go#L77-L113","documentation":"GetBytes (cmd/go/internal/web) successfully fetched the URL and Response.Err was nil, but io.ReadAll on the response body failed mid-stream. The %s is the redacted URL; %v is the read error.","triggerScenarios":"Connection reset mid-body, truncated/chunked response, or body reader returns an error after headers were received.","commonSituations":"Flaky networks, CDN dropping the connection, large module zip interrupted, proxy timeout on long downloads.","solutions":["Retry the fetch (often transient)","Verify network stability and proxy timeouts","Use GOPROXY with retry/backoff; raise server read timeouts for large files"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Retry body reads on transient connection resets","Use a GOPROXY mirror with retry/backoff for large module downloads"],"tags":["go","web","network","io"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}