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 {