{"record":{"id":"892e0c1f4b36d5e3","repo":"ipfs/kubo","slug":"reading-download-w","errorCode":null,"errorMessage":"reading download: %w","messagePattern":"reading download: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/update_github.go","lineNumber":230,"sourceCode":"\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Set(\"User-Agent\", \"kubo/\"+version.CurrentVersionNumber)\n\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"downloading asset: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"download returned HTTP %d\", resp.StatusCode)\n\t}\n\n\tdata, err := io.ReadAll(io.LimitReader(resp.Body, maxDownloadSize+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading download: %w\", err)\n\t}\n\tif int64(len(data)) > maxDownloadSize {\n\t\treturn nil, fmt.Errorf(\"download exceeds maximum size of %d bytes\", maxDownloadSize)\n\t}\n\treturn data, nil\n}\n\n// downloadAndVerifySHA512 downloads the .sha512 sidecar file for the given\n// archive URL and verifies the archive data against it.\nfunc downloadAndVerifySHA512(ctx context.Context, data []byte, archiveURL string) error {\n\tsha512URL := archiveURL + \".sha512\"\n\tchecksumData, err := downloadAsset(ctx, sha512URL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"downloading checksum file: %w\", err)\n\t}\n\n\t// Parse \"<hex>  <filename>\\n\" format (standard sha512sum output).\n\tfields := strings.Fields(string(checksumData))","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/update_github.go#L212-L248","documentation":"downloadAsset reads the asset body through io.LimitReader capped at maxDownloadSize+1; this error wraps any failure during that streaming read (connection reset mid-body, timeout, TLS error, truncated transfer).","triggerScenarios":"The TCP/TLS connection drops while the response body is being read, GitHub CDN closes the connection early, a context deadline cancels the in-flight read, or a proxy severs the transfer mid-stream.","commonSituations":"Flaky or slow networks during large kubo archive downloads; NAT/firewall dropping long-lived connections; corporate proxies with idle timeouts; pulling over VPN or mobile links.","solutions":["Simply retry the update command — transient network drops are the usual cause","Check network stability (MTU issues, VPN, flaky Wi-Fi) for repeated failures","Increase client timeout tolerance by running on a stable connection; the context deadline may be too tight","Verify the GitHub CDN (objects.githubusercontent.com) is reachable, not blocked by a firewall"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := runUpdate()\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) || strings.Contains(err.Error(), \"reading download\") {\n\t\t// transient I/O failure mid-body: safe to retry the whole download\n\t\treturn retryWithBackoff(runUpdate, 3)\n\t}\n\treturn err\n}","preventionTips":["Run updates on a stable wired connection; avoid VPN/mobile links for large downloads","Check MTU/firewall settings if downloads repeatedly stall or reset","Retry promptly — the error is almost always transient","Verify the context/timeout given to the updater is generous enough for archive-sized transfers"],"tags":["network","io","download","truncated"],"backgroundTag":"connection-reset-during-download","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}