Problem/Motivation
If a developer enables the REST module, but not a formatter (such as HAL), the resulting error is fairly terse when hal_json is requested:
he website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException</em>: Not acceptable in <em class="placeholder">Drupal\Core\EventSubscriber\AcceptNegotiation406->onViewDetect406()</em> (line <em class="placeholder">37</em> of <em class="placeholder">core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php</em>).
Steps to reproduce
:
- Enable the REST module
- Grant anonymous users the
restful get entity:node permission
- Add a node
- From the command line:
curl http://d8.dev/node/1?_format=hal_json
- See the exception
Proposed resolution
The thrown exception could at the very least include the requested format, instead of just Not acceptable.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
jhedstromComment #4
jhedstromThis should fix the test.
Comment #5
klausiLooks good, I verified that the concatenated format which is user provided input does not pose a XSS risk. Looks like we are sanitizing those exception messages somewhere :-)
Comment #7
wim leersComment #8
dawehnerBack to RTBC
Comment #10
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x, thanks!