Respect / Respect/Rest

Exception and Error Handlers break content type negotiation

Open
#109 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.