{"record":{"id":"dd549f1decd8a0d8","repo":"kubernetes/kops","slug":"reading-body-q-w","errorCode":null,"errorMessage":"reading body %q: %w","messagePattern":"reading body %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/assetdata/tools/cmd/generatefileassets/main.go","lineNumber":67,"sourceCode":"\n\tflag.Parse()\n\n\tif hashFileURL == \"\" {\n\t\thashFileURL = filestoreBase + prefix + \"SHA256SUMS\"\n\t}\n\n\thttpResponse, err := http.Get(hashFileURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"downloading %q: %w\", hashFileURL, err)\n\t}\n\tif httpResponse.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"unexpected status getting %q: %v\", hashFileURL, httpResponse.Status)\n\t}\n\tdefer httpResponse.Body.Close()\n\n\tb, err := io.ReadAll(httpResponse.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading body %q: %w\", hashFileURL, err)\n\t}\n\n\tm := &manifest{}\n\tfor _, line := range strings.Split(string(b), \"\\n\") {\n\t\tline = strings.TrimSpace(line)\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif line == \"-----BEGIN PGP SIGNED MESSAGE-----\" {\n\t\t\t// Start of the PGP boilerplate\n\t\t\tcontinue\n\t\t}\n\t\tif line == \"-----BEGIN PGP SIGNATURE-----\" {\n\t\t\t// Part of the PGP signature; end of signed content\n\t\t\tbreak\n\t\t}\n\t\tif line == \"Hash: SHA256\" {\n\t\t\t// Part of the PGP boilerplate","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetdata/tools/cmd/generatefileassets/main.go#L49-L85","documentation":"run() reads the full HTTP response body of the SHA256SUMS download with io.ReadAll; a mid-stream failure (connection reset, timeout, truncated response) yields this wrapped error. The URL is reported so the failing source is identifiable.","triggerScenarios":"io.ReadAll fails while consuming the hash-file response body — dropped connections, proxy termination, or server closing the stream early.","commonSituations":"Flaky network or CI runner; large/signed sum files interrupted by aggressive proxies; transient storage-backend errors mid-transfer.","solutions":["Rerun the tool; the failure is usually transient","Check network stability / disable interfering proxies or VPNs","Fetch the file manually with curl/wget to confirm server-side integrity, then retry","Add a retry loop around the tool invocation in CI"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"b, err := io.ReadAll(httpResponse.Body)\nif err != nil {\n\t// transient mid-stream failure: retry the whole request with backoff\n\treturn retryable(fmt.Errorf(\"reading body %q: %w\", hashFileURL, err))\n}","preventionTips":["Retry transient body-read failures with exponential backoff","Avoid running the generator over unstable networks/VPNs","Set sane client timeouts instead of the default http.Get client","Validate downloaded file length/format after reading"],"tags":["network","http-body","io"],"backgroundTag":"http-body-read-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}