Skip to content

[Messenger] flatternException->getTraceAsString() returns null sometimes, which causes exceptions #32487

Closed
@wtorsi

Description

@wtorsi

4.3.2

When $flattenException is built from $lastRedeliveryStamp in Symfony\Component\Messenger\Command\AbstractFailedMessagesCommand:76 it may contains null in traceAsString. Which causes exceptions in Symfony\Component\Messenger\Command\AbstractFailedMessagesCommand:103, because SymfonyStyle does not like nulls as messages.

        $flattenException = null === $lastRedeliveryStamp ? null : $lastRedeliveryStamp->getFlattenException();
            $io->title('Exception:');
            $io->writeln(null === $flattenException ? '(no data)' : $flattenException->getTraceAsString());

Actually, I don't know how to simply reproduce this exception.
I got this exception, trying sending Email through Mailer, while generating body in Email. (A message must have a text and/or an HTML part.)

As a solution i could recommend the following:

  1. Add strong (?string) type-hinting for Symfony\Component\Debug\Exception\FlattenException::getTraceAsString
  2. Do check not only for null === $flattenException in Symfony\Component\Messenger\Command\AbstractFailedMessagesCommand:103, but either check null === $flattenException->getTraceAsString()`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions