LegacyTypedDataNormalizer conflicts with JSON:API serialization
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3568588. --> Reported by: [alexismmd](https://www.drupal.org/user/3559279) Related to !69 !72 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The Tool module provides a global Symfony serializer normalizer<br> LegacyTypedDataNormalizer, which normalizes TypedDataInterface objects.</p> <p>JSON:API relies heavily on its own dedicated normalizers and assumes full<br> control over the serialization process when the jsonapi format is used.</p> <p>Currently, the Tool normalizer may be invoked during JSON:API requests,<br> causing conflicts such as:</p> <p>Incorrectly normalized data</p> <p>Missing or malformed JSON:API responses</p> <p>500 errors during JSON:API requests</p> <p>This happens because the Tool normalizer does not restrict itself by format<br> and may intercept TypedData objects before JSON:API normalizers are applied.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Install Drupal 11.x</p> <p>Enable the following modules:</p> <p>JSON:API</p> <p>Tool</p> <p>Make a JSON:API request, for example:</p> <p><code>GET /jsonapi/node/article</code></p> <p>Observe serialization errors, incomplete responses, or unexpected behavior</p> <p>Disable the Tool module &rarr; JSON:API works correctly again</p> <p>When the jsonapi format is used, Tool&rsquo;s normalizer should not participate<br> in the serialization process, allowing JSON:API to use its own normalizers<br> without interference.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Update LegacyTypedDataNormalizer::supportsNormalization() to explicitly<br> exclude the jsonapi format (and JSON:API context).</p> <p>Optionally, lower the normalizer priority to ensure JSON:API normalizers are<br> always preferred.</p>
issue