kubernetes/kops · error

reading body %q: %w

Error message

reading body %q: %w

What it means

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.

Source

Thrown at pkg/assets/assetdata/tools/cmd/generatefileassets/main.go:67

	flag.Parse()

	if hashFileURL == "" {
		hashFileURL = filestoreBase + prefix + "SHA256SUMS"
	}

	httpResponse, err := http.Get(hashFileURL)
	if err != nil {
		return fmt.Errorf("downloading %q: %w", hashFileURL, err)
	}
	if httpResponse.StatusCode != 200 {
		return fmt.Errorf("unexpected status getting %q: %v", hashFileURL, httpResponse.Status)
	}
	defer httpResponse.Body.Close()

	b, err := io.ReadAll(httpResponse.Body)
	if err != nil {
		return fmt.Errorf("reading body %q: %w", hashFileURL, err)
	}

	m := &manifest{}
	for _, line := range strings.Split(string(b), "\n") {
		line = strings.TrimSpace(line)
		if line == "" {
			continue
		}
		if line == "-----BEGIN PGP SIGNED MESSAGE-----" {
			// Start of the PGP boilerplate
			continue
		}
		if line == "-----BEGIN PGP SIGNATURE-----" {
			// Part of the PGP signature; end of signed content
			break
		}
		if line == "Hash: SHA256" {
			// Part of the PGP boilerplate

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Rerun the tool; the failure is usually transient
  2. Check network stability / disable interfering proxies or VPNs
  3. Fetch the file manually with curl/wget to confirm server-side integrity, then retry
  4. Add a retry loop around the tool invocation in CI
Defensive patterns

Strategy: retry

Try / catch

b, err := io.ReadAll(httpResponse.Body)
if err != nil {
	// transient mid-stream failure: retry the whole request with backoff
	return retryable(fmt.Errorf("reading body %q: %w", hashFileURL, err))
}

Prevention

When it happens

Trigger: io.ReadAll fails while consuming the hash-file response body — dropped connections, proxy termination, or server closing the stream early.

Common situations: Flaky network or CI runner; large/signed sum files interrupted by aggressive proxies; transient storage-backend errors mid-transfer.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/dd549f1decd8a0d8. Report an issue: GitHub.