Skip to content

Commit

Permalink
Fixed Issue: guacsec#2195 500 error when sending empty JSON payload t…
Browse files Browse the repository at this point in the history
…o GraphQL server

Signed-off-by: Sithum Sathsara <[email protected]>
  • Loading branch information
000xs committed Oct 20, 2024
1 parent 721a42c commit f84b845
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f84b845

Please sign in to comment.