From dc62b55c367cb4fe4dd4106d28f11adc206838ab Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:50:28 +0200 Subject: [PATCH] chore: add body to error if we are unable to decode it --- decoderx/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/decoderx/http.go b/decoderx/http.go index 2c3e1c45..1bee7e04 100644 --- a/decoderx/http.go +++ b/decoderx/http.go @@ -231,7 +231,7 @@ func (t *HTTP) validateRequest(r *http.Request, c *httpDecoderOptions) error { } if method != "GET" { - if r.ContentLength == 0 && method != "GET" { + if r.ContentLength == 0 { return errors.WithStack(herodot.ErrBadRequest.WithReasonf(`Unable to decode HTTP Request Body because its HTTP Header "Content-Length" is zero.`)) } @@ -555,7 +555,7 @@ func (t *HTTP) decodeJSON(r *http.Request, destination interface{}, o *httpDecod dc := json.NewDecoder(bytes.NewReader(raw)) if err := dc.Decode(destination); err != nil { - return errors.WithStack(herodot.ErrBadRequest.WithReasonf("Unable to decode JSON payload: %s", err)) + return errors.WithStack(herodot.ErrBadRequest.WithReasonf("Unable to decode JSON payload: %s", err).WithDebugf("Received request body: %s", string(raw))) } if err := t.validatePayload(r.Context(), raw, o); err != nil {