From ffc7a9d261421de4031b386da030b696e88aa95d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 23 Mar 2026 22:01:53 -0400 Subject: [PATCH] fix(log): don't conflate body drain errors with HTTP errors --- internal/log/http.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/log/http.go b/internal/log/http.go index a4564ffdc50335e3944c44ccf0a9a562e2f6454a..cf791366392c1e41d037633e57a3c6d52ce3f907 100644 --- a/internal/log/http.go +++ b/internal/log/http.go @@ -63,6 +63,10 @@ func (h *HTTPRoundTripLogger) RoundTrip(req *http.Request) (*http.Response, erro } save, resp.Body, err = drainBody(resp.Body) + if err != nil { + slog.Error("Failed to drain response body", "error", err) + return resp, err + } if slog.Default().Enabled(req.Context(), slog.LevelDebug) { slog.Debug( "HTTP Response", @@ -72,10 +76,9 @@ func (h *HTTPRoundTripLogger) RoundTrip(req *http.Request) (*http.Response, erro "body", bodyToString(save), "content_length", resp.ContentLength, "duration_ms", duration.Milliseconds(), - "error", err, ) } - return resp, err + return resp, nil } func bodyToString(body io.ReadCloser) string {