Skip to content

Commit

Permalink
HMS-2714 stop processing if input validation fails
Browse files Browse the repository at this point in the history
Currently input validation failure does NOT cause processing to
stop.  If somehow the backend operation succeed, that can result in
a 400 Bad Request response, but the target backend operation
completed and database modifications potentially performed.
Also, the normal response data gets appended to the error message.

Update the validation middleware to stop processing when an input
validation error occurs, after setting the response status and body
content (error message).  As a result, no further processing will be
performed.
  • Loading branch information
frasertweedale committed Oct 18, 2023
1 parent 6d1dfb1 commit ad482ab
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/infrastructure/middleware/validate_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func RequestResponseValidatorWithConfig(config *RequestResponseValidatorConfig)
if err != nil {
c.Response().Header().Set(echo.HeaderContentType, "text/plain")
c.String(http.StatusBadRequest, err.Error())
return nil // stop processing
}
}

Expand Down

0 comments on commit ad482ab

Please sign in to comment.