From 43a156630f65dc60ec387d49a6fdab596e12cf8c Mon Sep 17 00:00:00 2001 From: Gero Posmyk-Leinemann Date: Tue, 4 Jun 2024 07:50:16 +0200 Subject: [PATCH] [bob] Log body of "Bad Request" responses (#19823) --- components/image-builder-bob/pkg/proxy/proxy.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/image-builder-bob/pkg/proxy/proxy.go b/components/image-builder-bob/pkg/proxy/proxy.go index f77fe15755..dbabc0d353 100644 --- a/components/image-builder-bob/pkg/proxy/proxy.go +++ b/components/image-builder-bob/pkg/proxy/proxy.go @@ -7,6 +7,7 @@ package proxy import ( "context" "fmt" + "io" "net/http" "net/http/httputil" "net/url" @@ -229,7 +230,12 @@ func (proxy *Proxy) reverse(alias string) *httputil.ReverseProxy { return true, nil } if resp.StatusCode == http.StatusBadRequest { - log.WithField("URL", resp.Request.URL.String()).Warn("bad request") + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + log.WithError(err).WithField("URL", resp.Request.URL.String()).Warn("failed to read response body") + } + + log.WithField("URL", resp.Request.URL.String()).WithField("Body", string(bodyBytes)).Warn("bad request") return true, nil }