DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in src/State/Provider/DeserializeProvider.php at the call around line 110 identified in the issue. Check how the project supports both Symfony Serializer 7.4 and 8.1, then run the relevant tests for invalid input with collect_denormalization_errors: true. Done means those tests pass without the Symfony 8.1 deprecation while Symfony 7.4 remains supported.
Written by the indexing model from the issue text.
Description
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) {
...
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 987
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 76
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
api-platform/core#8665 ·
Maintainers usually reply within 1 day
-
Doctrine\Orm\OrderExtension fails on SortDirectionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
api-platform/core#8660 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
api-platform/core#8649 ·
Maintainers usually reply within 1 day
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
api-platform/core#8648 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
api-platform/core#8647 ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
Translation TwigBridge
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
symfony/symfony-docs#23308 ·
Maintainers usually reply within 3 days
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
WordPress/hosting-handbook#506 ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
mirai-mamori/Sakurairo#1435 · 1 comment ·