jgraichen / restify

Restify is a experimental, parallel and pipelined Hypermedia API client
GNU Lesser General Public License v3.0
8 stars 2 forks source link

Handling invalid JSON bodies #31

Open franzliedke opened 4 years ago

franzliedke commented 4 years ago

We encountered this in a test case, where we were using Restify for making requests to our Rails app. This app answered with HTTP 400 for certain invalid parameters. However, Rails sometimes sets the Content-Type header even for requests with empty bodies. This header makes Restify interpret the empty body as JSON, which then raises an exception.

Possible solutions:

(Yes, the server is doing something wrong here, but more graceful error handling on the client side would probably be useful, too. At least I am not aware of a protocol for handling processing errors in Restify.)

franzliedke commented 3 years ago

Idea from @jgraichen: Ignore all errors when parsing relations, and throw when trying to access the parsed body data.

franzliedke commented 2 years ago

Same problem for the Msgpack processor.