core
core copied to clipboard
4.0 breaks error handling compatibility
API Platform version(s) affected: 4.x
Description
I can't seem to make our error handling integration tests pass on api-platform 4.x
How to reproduce
Here are the relevant parts of the configuration used in api-platform/core:3.*:
api_platform:
use_symfony_listeners: true
handle_symfony_errors: true
Test:
Scenario: Invalid request
When I add "Content-Type" header equal to "application/ld+json"
And I add "Accept" header equal to "application/json"
And I send a "POST" request to "/api/bulk-resend-activation-mail" with body:
"""
invalid input{
"""
Then the response status code should be 400
api-platform/core: 3.x:
api-platform/core: 4.x: (click to enlarge)
Possible Solution
Additional Context
Mhh you never reach this line right?
https://github.com/api-platform/core/blob/fcd9a0725fb9fab942b306e5d3cb0e96226ee63e/src/Symfony/EventListener/ExceptionListener.php#L50
Is your endpoint an API Resource?
Another lead would be that this patch https://github.com/api-platform/core/commit/7399fcf7eaf28cd649d137da1fdd54f69093e275 changes something in your case but I need to know if you reach the previous mentioned line first.
It does trigger that line. Inside, exception is rethrown as BadRequestHttpException, but that one doesn't seem to be handled further.
And that endpoint is not an API resource.
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.
I tried to reproduce at https://github.com/api-platform/core/commit/1096084e04e00bbfe80865db2ca95249c5f2dce1 but I successfully got a 400. To run the test:
USE_SYMFONY_LISTENERS=true vendor/bin/phpunit tests/Functional/Symfony/ErrorTest.php
Did I forgot something?
Hmm indeed, it looks some change has fixed this meanwhile :\