-
Notifications
You must be signed in to change notification settings - Fork 88
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
Bug: validation module should return 400 on error #1298
Comments
Not that simple as we perform some validation on many different events, not only API GW... 400 is only applicable to API GW events and responses ( |
Good point. Should we add some return-type specific behavior? The alternative seems to be saying we aren't supporting the annotation directly on the handlers function itself, but only on "other methods"; then in the case of a HTTP API integration, the user's handler wraps this "other method", catches the exception, and maps back to a 400. I feel that validation on a HTTP API is "common path" and should work without this level of glue. What do you reckon? |
Either we document how to not use the annotation and use the Either we implement this in the library : in case of one of the events above, we change the http code in the response to 400 and update the body with an error message... Probably a better experience for users but will be opinionated (message format: json? plain txt?). |
Let's tie this into the broader module-review issue for V2 - #1469. Oner person can knock both of these off at once. |
Happy to take that one |
… be catched and returned as a 400 error
…rigger a validation exception
…lidation failed response
… be catched and returned as a 400 error
…rigger a validation exception
…lidation failed response
This will be released with v2 |
When you use the
@Validation
annotation on aRequestHandler
and the provided message does not validate, the module will throw aValidationException
, resulting in a 500 back to the client.Changing this behaviour is a breaking change.
What were you trying to accomplish?
I would expect that validation errors should return a 400 and a description of why the validation failed. Alternatively if the annotation is applied to something other than a
RequestHandler
, throwing an exception for the user's code to catch seems reasonable.Current Behavior
ValidationException / HTTP 500 returned to user.
Possible Solution
Steps to Reproduce (for bugs)
Check out the validation example as it exhibits this behaviour.
The text was updated successfully, but these errors were encountered: