From 41a3322f0b2ea550e65d516938648ebb4ca85bcf Mon Sep 17 00:00:00 2001 From: Sithum Sathsara <89584440+SithumSathsaras@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:52:03 -0400 Subject: [PATCH] Fixed Issue: #2195 500 error when sending empty JSON payload to GraphQL server Signed-off-by: Sithum Sathsara <89584440+SithumSathsaras@users.noreply.github.com> --- pkg/metrics/prometheus.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/metrics/prometheus.go b/pkg/metrics/prometheus.go index 6b87e04db0..6603d06ddb 100644 --- a/pkg/metrics/prometheus.go +++ b/pkg/metrics/prometheus.go @@ -292,8 +292,7 @@ func (pc *prometheusCollector) MeasureGraphQLResponseDuration(next http.Handler) var graphqlRequest struct { OperationName string `json:"operationName"` } - // Check if the body is valid JSON - if !json.Valid(bodyCopy) { + if !json.Valid(bodyCopy) { // Check if the body is valid JSON err_msg := fmt.Sprintf("Provided input json couldn't be parsed. likely it was empty or was wrongly structured; error message: %v", err.Error()) http.Error(w, err_msg, http.StatusBadRequest) return