Skip to content

Deserialization bug on background job (IriConverter) #946

Description

@jhonatanTeixeira

I got the following error when trying to consume a amqp message on a background job, i got this consumer1_1 prefixed because its a docker container running with the provided Dockerfile by the api platform skeleton.

consumer1_1      | 
consumer1_1      |                                                          
consumer1_1      |   [ApiPlatform\Core\Exception\InvalidArgumentException]  
consumer1_1      |   No route matches "1".                                  
consumer1_1      |                                                          
consumer1_1      | 
consumer1_1      | Exception trace:
consumer1_1      |  () at /app/vendor/api-platform/core/src/Bridge/Symfony/Routing/IriConverter.php:61
consumer1_1      |  ApiPlatform\Core\Bridge\Symfony\Routing\IriConverter->getItemFromIri() at /app/vendor/api-platform/core/src/Serializer/ItemNormalizer.php:36
consumer1_1      |  ApiPlatform\Core\Serializer\ItemNormalizer->denormalize() at /app/vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php:264
consumer1_1      |  Symfony\Component\Serializer\Serializer->denormalizeObject() at /app/vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php:174
consumer1_1      |  Symfony\Component\Serializer\Serializer->denormalize() at /app/vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php:132
consumer1_1      |  Symfony\Component\Serializer\Serializer->deserialize() at /app/src/AppBundle/Amqp/SaveEntityConsumer.php:41
consumer1_1      |  AppBundle\Amqp\SaveEntityConsumer->execute() at n/a:n/a
consumer1_1      |  call_user_func() at /app/vendor/php-amqplib/rabbitmq-bundle/RabbitMq/Consumer.php:88
consumer1_1      |  OldSound\RabbitMqBundle\RabbitMq\Consumer->processMessageQueueCallback() at /app/vendor/php-amqplib/rabbitmq-bundle/RabbitMq/Consumer.php:133
consumer1_1      |  OldSound\RabbitMqBundle\RabbitMq\Consumer->processMessage() at n/a:n/a
consumer1_1      |  call_user_func() at /app/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php:983
consumer1_1      |  PhpAmqpLib\Channel\AMQPChannel->basic_deliver() at n/a:n/a
consumer1_1      |  call_user_func() at /app/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:202
consumer1_1      |  PhpAmqpLib\Channel\AbstractChannel->dispatch() at /app/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php:341
consumer1_1      |  PhpAmqpLib\Channel\AbstractChannel->wait() at /app/vendor/php-amqplib/rabbitmq-bundle/RabbitMq/Consumer.php:54
consumer1_1      |  OldSound\RabbitMqBundle\RabbitMq\Consumer->consume() at /app/vendor/php-amqplib/rabbitmq-bundle/Command/BaseConsumerCommand.php:90
consumer1_1      |  OldSound\RabbitMqBundle\Command\BaseConsumerCommand->execute() at /app/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:262
consumer1_1      |  Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:848
consumer1_1      |  Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:189
consumer1_1      |  Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
consumer1_1      |  Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:120
consumer1_1      |  Symfony\Component\Console\Application->run() at /app/bin/console:27

This is the code that causes the excpetion as seen on the trace, located on the SaveEntityConsumer:

    public function execute(AMQPMessage $msg)
    {
        $data = unserialize($msg->body);
        
        $entity = $this->serializer->deserialize($data['entityData'], $data['type'], 'json');
        
        foreach ($this->observers as $observer) {
            if ($observer->accept($entity)) {
                $observer->consume($entity);
                
                return;
            }
        }
    }

The serializer is being injected on the constructor and is the symfony serializer provided by the framework itself. Is there something i must do to fix this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions