Skip to content

Attempted to call function "is_mixed" from the global namespace for "symfony/doctrine-messenger" package #58225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
e-repo opened this issue Sep 10, 2024 · 1 comment

Comments

@e-repo
Copy link

e-repo commented Sep 10, 2024

Symfony version(s) affected

7.1.1

Description

I may have missed something, but I encountered a problem when trying to call the is_mixed function from the global scope while using the symfony/doctrine-messenger package.

This error occurs when attempting to execute the following commands:
messenger:consume failed
messenger:failed:retry

The issue arises because the TransportMessageIdStamp object cannot be constructed from the "X-Message-Stamp-Symfony\Component\Messenger\Stamp\TransportMessageIdStamp" header during the execution of Symfony\Component\Serializer\Serializer::deserialize(...).

The root cause is the mixed type of the id in TransportMessageIdStamp.

abstract class AbstractObjectNormalizer extends AbstractNormalizer
{
    ...
    if (('is_'.$typeIdentifier->value)($data)) {
        return $data;
    }
    ...
}

The TransportMessageIdStamp looks like this:

final class TransportMessageIdStamp implements StampInterface
{
    public function __construct(
        private mixed $id,
    ) {
    }

    public function getId(): mixed
    {
        return $this->id;
    }
}

How to reproduce

To reproduce this issue, follow these steps:

  1. Send a message to the "failure_transport" in any way while it hasn't appeared in the database via symfony/doctrine-messenger.
  2. Run messenger:failed:retry or messenger:consume failed, preferably retry, followed by writing the message back to the database (simulating an unresolved issue in the handler).
  3. During this process, the attempt to create TransportMessageIdStamp from X-Message-Stamp-Symfony\Component\Messenger\Stamp\TransportMessageIdStamp fails with an error.

Possible Solution

It might make sense to specify a more precise type in TransportMessageIdStamp, possibly using a union type.

For example:

final class TransportMessageIdStamp implements StampInterface
{
    public function __construct(
        private int|string $id,
    ) {
    }

    public function getId(): mixed
    {
        return $this->id;
    }
}

Additional Context

No response

@derrabus
Copy link
Member

Duplicate of #57314

@derrabus derrabus marked this as a duplicate of #57314 Sep 10, 2024
@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants