Skip to content

Commit

Permalink
Merge pull request #319 from xmidt-org/wrp-validation-update
Browse files Browse the repository at this point in the history
typo
  • Loading branch information
maurafortino authored Nov 14, 2023
2 parents f674634 + f48a1df commit 0b1e5e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Binary file modified cpuprofile
Binary file not shown.
5 changes: 2 additions & 3 deletions primaryHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,12 @@ func ValidateWRP(logger *zap.Logger) func(http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

if msg, ok := wrpcontext.GetMessage(r.Context()); ok {
var err error
var failureError error
var warningErrors error

validators := wrp.SpecValidators()
for _, v := range validators {
err = v.Validate(*msg)
err := v.Validate(*msg)
if errors.Is(err, wrp.ErrorInvalidMessageEncoding.Err) || errors.Is(err, wrp.ErrorInvalidMessageType.Err) {
failureError = multierr.Append(failureError, err)
} else if errors.Is(err, wrp.ErrorInvalidDestination.Err) || errors.Is(err, wrp.ErrorInvalidSource.Err) {
Expand All @@ -595,7 +594,7 @@ func ValidateWRP(logger *zap.Logger) func(http.Handler) http.Handler {
w,
`{"code": %d, "message": "%s"}`,
http.StatusBadRequest,
fmt.Sprintf("failed to validate WRP message: %s", err))
fmt.Sprintf("failed to validate WRP message: %s", failureError))
return
}
}
Expand Down

0 comments on commit 0b1e5e9

Please sign in to comment.