Invalid submitted json is reported as server error
API Platform version(s) affected: 2.6.8
Description
When invalid JSON is being submitted to a POST endpoint, a 500 status code is being returned even though invalid input is a user error, not that of the server. A proper status code for this case would be 400, I think.
How to reproduce
Submit intentionally broken JSON body to a POST endpoint, e.g., without a closing brace.
For a quick demo:
- Open https://demo.sylius.com/api/v2/.
- Find the group of requests named "Customer".
- Expand the POST endpoint
- paste the following body and submit the request:
{ "firstName": "John", "lastName": "Doe", "email": "[email protected]", "password": "Password", "subscribedToNewsletter": true - Note that you get a 500 server error. If you add the missing brace, you'll get an expected response code (204 or 422).
It's actually weird that default configuration doesn't come with:
exception_to_status:
Symfony\Component\Serializer\Exception\ExceptionInterface: 400
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Has it really been fixed though?