Skip to content

DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1 #8650

Closed

Description

@MarcinOrlowski

API Platform version(s) affected: 4.3.21 and the current head of 4.4 (5.0 is not affected)

Symfony 8.1 deprecates PartialDenormalizationException::getErrors() in favour of getNotNormalizableValueErrors(). The 4.4 branch still calls it: https://github.com/api-platform/core/blob/4.4/src/State/Provider/DeserializeProvider.php#L110

Since symfony/serializer 8.1: The "Symfony\Component\Serializer\Exception\PartialDenormalizationException::getErrors()" method is deprecated, use "Symfony\Component\Serializer\Exception\PartialDenormalizationException::getNotNormalizableValueErrors()" instead.

Every 422 caused by a denormalization error goes through this line, so with collect_denormalization_errors: true it shows up in each test that sends invalid input. 5.0 no longer has the call, but it went away with the rewrite in #8211, which won't be backported.

Possible solution

In Symfony 8.1 getErrors() only returns getNotNormalizableValueErrors(), so the swap is exact. 4.4 also supports symfony/serializer ^7.4, which doesn't have that method, so the fallback would be needed. Yet the fix seems as trivial as

$errors = method_exists($e, 'getNotNormalizableValueErrors')
    ? $e->getNotNormalizableValueErrors()
    : $e->getErrors();

foreach ($errors as $exception) {
    ...

Activity

  1. soyuka commented on Oct 13, 2026

    @soyuka
    Member

    Fixed by #8663 on 4.4, the 5.0 line already has the same guard.

  2. added a commit that references this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions