Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support handling javax.validation.ConstraintViolationException #53

Open
nicmunroe opened this issue Mar 31, 2020 · 0 comments
Open

Support handling javax.validation.ConstraintViolationException #53

nicmunroe opened this issue Mar 31, 2020 · 0 comments

Comments

@nicmunroe
Copy link
Member

If a spring controller is annotated with @org.springframework.validation.annotation.Validated, an endpoint argument is annotated with JSR 303 validation annotations (e.g. @Valid @NotBlank(message = "SOME_API_ERROR") @RequestParam(name = "fooParam") String fooParam), and a request comes in that violates those JSR 303 annotations, then yet another codepath is executed that ends up causing a javax.validation.ConstraintViolationException to be thrown.

We could handle this in backstopper with ClientDataValidationErrorHandlerListener, as the intention is the same and ClientDataValidationErrorHandlerListener is already setup to deal with the same ConstraintViolations that ConstraintViolationException contains. The result would have less info in the backstopper log message, but it would at least be handled properly instead of falling through to the generic 500 fallback handler.

NOTE: We'd need to make sure that the reusable JSR 303 convention tests cover this case (JSR 303 annotations on arbitrary method arguments) as well as the normal model object case.

@nicmunroe nicmunroe changed the title Support handling javax.validation.ConstraintViolationException Support handling javax.validation.ConstraintViolationException Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant