-
-
Notifications
You must be signed in to change notification settings - Fork 957
Description
API Platform version(s) affected: 2.7.1 & 3.0.1
Description
Im using enums in my entities. Before the upgrade, it was working without problems. After upgrading to 2.7 and later to 3.0, all queries to endpoints (GET , GetCollection , POST) result in 500 with the following exception
TypeError : App\Enum\ActionType::from(): Argument #1 ($value) must be of type string, App\Enum\ActionType given
I had the same error before touching any code and metadata_backward_compatibility_layer true.
The property looks like this
#[ORM\Column(length: 20)]
#[Groups(['port:read'])]
private ActionType $type;
and the Enum is
enum ActionType: string
{
case PROVISION = 'PROVISION';
case DEPROVISION = 'DEPROVISION';
case RESTART = 'RESTART';
}
The full error stacktrace is
project\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionEnumProperty.php:93
project\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ReflectionEnumProperty.php:77
project\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php:2745
project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:266
project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:436
project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php:148
project\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\AbstractHydrator.php:270
project\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php:1224
project\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php:1165
project\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php:901
project\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Pagination\Paginator.php:171
project\vendor\api-platform\core\src\Doctrine\Orm\AbstractPaginator.php:69
project\vendor\api-platform\core\src\Hydra\Serializer\CollectionNormalizer.php:84
project\vendor\api-platform\core\src\Hydra\Serializer\PartialCollectionViewNormalizer.php:47
project\vendor\api-platform\core\src\Hydra\Serializer\CollectionFiltersNormalizer.php:61
project\vendor\symfony\serializer\Serializer.php:161
project\vendor\symfony\serializer\Serializer.php:134
project\vendor\api-platform\core\src\Symfony\EventListener\SerializeListener.php:95
project\vendor\symfony\event-dispatcher\Debug\WrappedListener.php:115
project\vendor\symfony\event-dispatcher\EventDispatcher.php:230
project\vendor\symfony\event-dispatcher\EventDispatcher.php:59
project\vendor\symfony\event-dispatcher\Debug\TraceableEventDispatcher.php:153
project\vendor\symfony\http-kernel\HttpKernel.php:158
project\vendor\symfony\http-kernel\HttpKernel.php:75
project\vendor\symfony\http-kernel\Kernel.php:202
project\vendor\symfony\http-kernel\HttpKernelBrowser.php:65
project\vendor\symfony\framework-bundle\KernelBrowser.php:172
project\vendor\symfony\browser-kit\AbstractBrowser.php:370
project\vendor\api-platform\core\src\Symfony\Bundle\Test\Client.php:116
How to reproduce
Possible Solution
Additional Context
Some dependencies were updated when installing apip 2.7 and doctrine/orm was bumped from 2.12.3 => 2.13.2
I will check if that had some side effects unrelated to apip upgrade.