Exception and Error Handlers break content type negotiation
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 605
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
It would be nice to actually have the Exception and Error Routes be treated the same as all other types or Route objects. Instead what happens is the minute there's an exception, all of the accept() routine functionality is completely ignored and a call is made to these handlers that just spits that content out as is without any regard to the Accept header. This breaks parsers that are expecting valid content responses.
On top of this issue, if you return an empty string to try to at least prevent the parsing issues without giving any detail to the cause, it still breaks. It appears that the Request object is doing lazy comparisons with what was returned from the Exception handler and if it's an empty value, it assumes that the handler failed and then rethrows the exception.
This is basically a deal breaker since my choice is to not handle exceptions and have the API break entirely, or return non valid content results and have the API parsers break on the client side. Both completely unacceptable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Exception and Error Routes, the accept() routine, and the Request object behavior described in the issue. Reproduce an exception with different Accept headers and with an empty handler response. Done means exception responses undergo content negotiation and an empty response does not cause the original exception to be rethrown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100