golang/go · error

reading %s: %v

Error message

reading %s: %v

What it means

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.

Source

Thrown at src/cmd/go/internal/web/api.go:95

	return e.Err
}

// GetBytes returns the body of the requested resource, or an error if the
// response status was not http.StatusOK.
//
// GetBytes is a convenience wrapper around Get and Response.Err.
func GetBytes(u *url.URL) ([]byte, error) {
	resp, err := Get(DefaultSecurity, u)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if err := resp.Err(); err != nil {
		return nil, err
	}
	b, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("reading %s: %v", u.Redacted(), err)
	}
	return b, nil
}

type Response struct {
	URL        string // redacted
	Status     string
	StatusCode int
	Header     map[string][]string
	Body       io.ReadCloser // Either the original body or &errorDetail.

	fileErr     error
	errorDetail errorDetailBuffer
}

// Err returns an *HTTPError corresponding to the response r.
// If the response r has StatusCode 200 or 0 (unset), Err returns nil.
// Otherwise, Err may read from r.Body in order to extract relevant error detail.

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Retry the fetch (often transient)
  2. Verify network stability and proxy timeouts
  3. Use GOPROXY with retry/backoff; raise server read timeouts for large files
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: Connection reset mid-body, truncated/chunked response, or body reader returns an error after headers were received.

Common situations: Flaky networks, CDN dropping the connection, large module zip interrupted, proxy timeout on long downloads.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/fcea4eab9cae5482. Report an issue: GitHub.