Core: IriConverter can't retrieve item from iri

Created on 21 Jul 2017  路  6Comments  路  Source: api-platform/core

Hello, I found a bug with the IriConverter, on the v2.1.
When I try to get an item using IriConverter::getItemFromIri from a custom action, I get a RuntimeException('Request attributes are not valid.').
This happens because my custom action doesn't have a resource_class defined, but it seems to be needed for the IriConverter to retrieve the serialization group to use for the item.
There were no problem with this on the v2.0.

Here is the stack trace :

#1 /var/www/symfony/vendor/api-platform/core/src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php(225): ApiPlatform\Core\Serializer\SerializerFilterContextBuilder->createFromRequest(Object(Symfony\Component\HttpFoundation\Request), true, Array)
#2 /var/www/symfony/vendor/api-platform/core/src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php(101): ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension->getSerializerGroups('Stadline\\Shadow...', Array, 'normalization_c...')
#3 /var/www/symfony/vendor/api-platform/core/src/Bridge/Doctrine/Orm/ItemDataProvider.php(88): ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension->applyToItem(Object(Doctrine\ORM\QueryBuilder), Object(ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator), 'Stadline\\Shadow...', Array, NULL, Array)
#4 /var/www/symfony/vendor/api-platform/core/src/DataProvider/ChainItemDataProvider.php(42): ApiPlatform\Core\Bridge\Doctrine\Orm\ItemDataProvider->getItem('Stadline\\Shadow...', '10', NULL, Array)
#5 /var/www/symfony/vendor/api-platform/core/src/Bridge/Symfony/Routing/IriConverter.php(82): ApiPlatform\Core\DataProvider\ChainItemDataProvider->getItem('Stadline\\Shadow...', '10', NULL, Array)

All 6 comments

We stumbled on this also and just declared a _resource_class to avoid this error on custom operation

Yes this is now mandatory... Do you think it's an important BC break? Maybe a note in the changelog is enough?

@dunglas Documenting even "minor" BC breaks would be very much appreciated!

Can we remove this BC break actually?

We should at least document it. Removing it would definitely be better.

ping @dunglas

Was this page helpful?
0 / 5 - 0 ratings