JuliusBrussee/caveman · error

rewriter: read response: %w

Error message

rewriter: read response: %w

What it means

Reading the rewriter provider's (2xx) response body failed at the transport level — a dropped connection mid-body or read timeout. The status line succeeded but the payload could not be fully received, so decoding cannot proceed.

Source

Thrown at rewriter/provider.go:206

		return nil, fmt.Errorf("rewriter: %s: %w", endpoint, err)
	}
	// An injected doer is caller code; a nil response or body must surface as an
	// error rather than a panic inside the proxy hot path.
	if resp == nil {
		return nil, fmt.Errorf("rewriter: %s: nil response", endpoint)
	}
	if resp.Body == nil {
		resp.Body = http.NoBody
	}
	defer resp.Body.Close()

	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		detail, _ := io.ReadAll(io.LimitReader(resp.Body, maxErrorBody))
		return nil, fmt.Errorf("rewriter: %s: status %d: %s", endpoint, resp.StatusCode, strings.TrimSpace(string(detail)))
	}
	raw, err := io.ReadAll(io.LimitReader(resp.Body, maxProviderResponseBody+1))
	if err != nil {
		return nil, fmt.Errorf("rewriter: read response: %w", err)
	}
	if len(raw) > maxProviderResponseBody {
		return nil, fmt.Errorf("rewriter: response exceeds %d bytes", maxProviderResponseBody)
	}
	return raw, nil
}

View on GitHub (pinned to 766dce6b13)

Solutions

  1. Retry the request; interrupted body reads are typically transient
  2. Increase the read timeout if bodies are large and the connection is slow
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at rewriter/provider.go:206 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/a4ce6e9fd228ca40. Report an issue: GitHub.