-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Invalid body parse error not rescued by handlers #906
Invalid body parse error not rescued by handlers #906
Conversation
4a2ddac
to
6edfbea
Compare
@@ -81,6 +81,9 @@ def read_rack_input(body) | |||
end | |||
env['rack.request.form_input'] = env['rack.input'] | |||
end | |||
rescue MultiJson::ParseError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is specific to the JSON parser, so it should be in it, not here. Then you can raise a Grape::Exception::InvalidMessageBody
error and re-rescue and just re-raise anything that is Grape::Exception::Base
here.
You might want to look at other parsers while you're at it, maybe the XML one has a similar problem and can be fixed in the same way?
This is good work, see my comments. |
ef1fd15
to
f69ded9
Compare
Found (and fixed) the same issue to appear when using the XML parser. |
@@ -9,6 +9,7 @@ Next Release | |||
* [#901](https://github.com/intridea/grape/pull/901): Fix: callbacks defined in a version block are only called for the routes defined in that block - [@kushkella](https://github.com/kushkella). | |||
* [#886](https://github.com/intridea/grape/pull/886): Group of parameters made to require an explicit type of Hash or Array - [@jrichter1](https://github.com/jrichter1). | |||
* [#912](https://github.com/intridea/grape/pull/912): Extended the `:using` feature for param documentation to `optional` fields - [@croeck](https://github.com/croeck). | |||
* [#906](https://github.com/intridea/grape/pull/906): Fix: invalid body parse errors are not rescued by handlers [@croeck](https://github.com/croeck). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: this is missing a dash. before your github name.
See my minor comments. Will merge after, great work. |
… error that translates into a customized bad request response (+spec)
f69ded9
to
3479ba0
Compare
Ok, fixed your comments and the build just passed :) |
…ued-by-handlers Invalid body parse error not rescued by handlers
Merged, thanks. |
Please see issue #904 for a more detailed description. The spec with content_type
application/json
fails and is not processed byrescue_from :all
.