GET requests broken
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3458259. -->
Reported by: [jsacksick](https://www.drupal.org/user/972218)
Related to !16
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>In the process of fixing a deprecation as part of <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/jsonapi_resources/-/work_items/3362189" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/jsonapi_resources/-/work_items/3362189</a></span>, a serious regression was introduced by mistake.<br>
I blindly updated jsonapi_resources, but GET requests to custom JSONAPI resources are now broken due to the change linked.</p>
<p>The <code>Drupal\jsonapi_resources\Unstable\Controller\ArgumentResolver::DocumentResolver</code> now implements the <code>Symfony\Component\HttpKernel\Controller\ValueResolverInterface</code> and as a consequence, the supports() method is no longer invoked.</p>
<p><code>Symfony\Component\HttpKernel\Controller\ArgumentResolver::getArguments()</code> has the following code:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br> </span><span style="color: #007700">if ((!</span><span style="color: #0000BB">$resolver </span><span style="color: #007700">instanceof </span><span style="color: #0000BB">ValueResolverInterface </span><span style="color: #007700">|| </span><span style="color: #0000BB">$resolver </span><span style="color: #007700">instanceof </span><span style="color: #0000BB">TraceableValueResolver</span><span style="color: #007700">) && !</span><span style="color: #0000BB">$resolver</span><span style="color: #007700">-></span><span style="color: #0000BB">supports</span><span style="color: #007700">(</span><span style="color: #0000BB">$request</span><span style="color: #007700">, </span><span style="color: #0000BB">$metadata</span><span style="color: #007700">)) {<br> continue;<br> }<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>Our resolver now implements the ValueResolverInterface so this condition no longer passes, and our resolver is no longer skipped, causing the following to happen:</p>
<p><code>DocumentResolver::resolve()</code> calls <code>$this->documentExtractor->getDocument($request);</code> which calls later in the process <code>Drupal\jsonapi_resources\Unstable\DocumentExtractor::decodeRequestPayload()</code> which throws the following exception:</p>
<p><code> throw new BadRequestHttpException('Empty request body.');</code>.</p>
<p>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/*).</p>
<p>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()? </p>
issue