Problem/Motivation
In the process of fixing a deprecation as part of
📌
Implement ValueResolverInterface instead of ArgumentValueResolverInterface
Active
, a serious regression was introduced by mistake.
I blindly updated jsonapi_resources, but GET requests to custom JSONAPI resources are now broken due to the change linked.
The Drupal\jsonapi_resources\Unstable\Controller\ArgumentResolver::DocumentResolver
now implements the Symfony\Component\HttpKernel\Controller\ValueResolverInterface
and as a consequence, the supports() method is no longer invoked.
Symfony\Component\HttpKernel\Controller\ArgumentResolver::getArguments()
has the following code:
if ((!$resolver instanceof ValueResolverInterface || $resolver instanceof TraceableValueResolver) && !$resolver->supports($request, $metadata)) {
continue;
}
Our resolver now implements the ValueResolverInterface so this condition no longer passes, and our resolver is no longer skipped, causing the following to happen:
DocumentResolver::resolve()
calls $this->documentExtractor->getDocument($request);
which calls later in the process Drupal\jsonapi_resources\Unstable\DocumentExtractor::decodeRequestPayload()
which throws the following exception:
throw new BadRequestHttpException('Empty request body.');
.
In short, we're trying to extract the document passed alongside the request for a GET request. This basically breaks my Commerce API resources (e.g: /jsonapi/checkout/*).
Not really sure why this functionality got deprecated in Symfony... They tell you to use resolve() instead, but what should be the behavior when there is nothing to do? Simply return an empty array()?