on main help sign in
fix(log): don't conflate body drain errors with HTTP errors
commitffc7a9d261421de4031b386da030b696e88aa95d authorChristian Rocha <christian@rocha.is> dateMon 23 Mar 2026, 22:01 (7 months ago) parent6920cf1
1 file changed+5−2
internal/log/http.go+5−2
internal/log/http.go+5−2
@@ -63,6 +63,10 @@ func (h *HTTPRoundTripLogger) RoundTrip(req *http.Request) (*http.Response, erro
6363 }
6464
6565 save, resp.Body, err = drainBody(resp.Body)
66+ if err != nil {
67+ slog.Error("Failed to drain response body", "error", err)
68+ return resp, err
69+ }
6670 if slog.Default().Enabled(req.Context(), slog.LevelDebug) {
6771 slog.Debug(
6872 "HTTP Response",
@@ -72,10 +76,9 @@ func (h *HTTPRoundTripLogger) RoundTrip(req *http.Request) (*http.Response, erro
7276 "body", bodyToString(save),
7377 "content_length", resp.ContentLength,
7478 "duration_ms", duration.Milliseconds(),
75− "error", err,
7679 )
7780 }
78− return resp, err
81+ return resp, nil
7982}
8083
8184func bodyToString(body io.ReadCloser) string {