api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 882 forks source link

[3.4.3] BC break in Symfony 6.4 - Attempted to call an undefined method named "getSupportedTypes" #6822

Open perice opened 3 days ago

perice commented 3 days ago

API Platform version(s) affected: x.y.z 3.4.3 and above

Description
Upgrading from 3.4.2 to 3.4.3 breaks the app because the added ErrorNormalizer wants to call getSupportedTypes() on the inner class which doesn't exist.

Breaks with Symfony 6.4, as the method is not part of the NormalizerInterface:

https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php

Break caused by adding ErrorNormalizer:

https://github.com/api-platform/core/compare/v3.4.2...v3.4.3

How to reproduce
Use Symfony 6.4.* Use Api Platform 3.4.3+ Not sure - Make it throw an error? or just call getSupportedTypes on something?

Possible Solution
Add getSupportedTypes() to everything that extends the NormalizerInterface Rewrite the ErrorNormalizer to not call getSupportedTypes() if undefined

soyuka commented 3 days ago

I'd like to know the source of the error, does https://github.com/api-platform/core/pull/6825 fixes your issue?

perice commented 3 days ago

Yes, it fixes the issue.

Thanks!