Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The following causes an assert error:
$url = Url::fromRoute('commerce_cart_api.jsonapi.cart_clear', ['commerce_order' => $cart->uuid()]);
$response = $this->request('DELETE', $url, $this->getAuthenticationRequestOptions());
Exception : AssertionError: assert($document instanceof JsonApiDocumentTopLevel)
assert()() (Line: 105)
\Drupal\jsonapi_resources\Controller\JsonapiResourceController::ensureValidResponseDataResourceTypes should properly handle DELETE / 204 requests that have no body.
Comment | File | Size | Author |
---|---|---|---|
#7 | 3090971-7.patch | 3.34 KB | mglaman |
Comments
Comment #2
mglamanWe should also relax
\Drupal\jsonapi_resources\Routing\ResourceRoutes::ensureResourceImplementationValid
if the method is only ['DELETE']Comment #3
mglamanComment #4
mglamanHere is a patch. If the response code is not 204, then we ensure the resource types. I also skip the route validation if the methods are specifically only ['DELETE']
Comment #5
gabesulliceOverall, I'm 👍. Just two nits:
Feels like this should go inside the method and if the response is 204, we should validate that there actually isn't any content.
Instead of creating another level of nesting, what about an early return?
Comment #6
mglaman😂I originally had this and went "nah". I'll go back!
Going to try and make better words for this:
👍
Comment #7
mglamanI had bad logic in that last patch, 204 response still threw an assert error.
Comment #9
mglamanUnblock DELETE requests!