Discovered while working on #2930028: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only.
From #2930028-9: Comprehensive JSON API integration test coverage phase 1: for every entity type, individual resources only's test results:
--- Expected
+++ Actual
@@ @@
-{"errors":[{"title":"Unprocessable Entity","status":422,"detail":"Unprocessable Entity: validation failed.\ntitle: Title: this field cannot hold more than 1 values.\n","links":{"info":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html"},"code":0}]}
+{"errors":[{"title":"Unprocessable Entity","status":422,"detail":"There was an error un-serializing the data. Message: Deserialization for the format is not supported","links":{"info":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html"},"code":0}]}
That is directly caused by \Drupal\jsonapi\Controller\RequestHandler::deserializeBody() doing this:
$format = $request->getContentType();
…
try {
return $serializer->deserialize($received, $serialization_class, $format, [
… ]);
}
Comments
Comment #2
wim leers#2934149: [>=8.5] JSON API routes not specifying _content_type_format route requirement, resulting in bad DX would've solved the root cause, and would've resulted in this not mattering, but there nevertheless is no point in making this dynamic when we can just hardcode it to
api_json.Comment #3
wim leersSo this is apparently breaking an existing JSON API test. That test does:
That looks as if it's testing that there's a helpful error response for a missing
Content-Typerequest header. But the response looks like this:So: — that's not remotely helpful.
The actually helpful error response would be added by #2934149: [>=8.5] JSON API routes not specifying _content_type_format route requirement, resulting in bad DX. I'm commenting this test coverage for now, in favor of #2934149: [>=8.5] JSON API routes not specifying _content_type_format route requirement, resulting in bad DX.
Comment #5
wim leersComment #6
e0ipsoI agree the error message could be better, but I think it's better than nothing. Let's put the improved version back soon so we don't forget about this.
Comment #7
wim leersWe won't forget about this, because A) there's a
@todo, B) there's an issue that it points to: #2934149: [>=8.5] JSON API routes not specifying _content_type_format route requirement, resulting in bad DX.