Skip to content

fix(symfony-messenger): hook the handler closure on symfony messenger 8.2 - #4597

Open
mstegmeyer wants to merge 1 commit into
DataDog:masterfrom
mstegmeyer:fix/symfony-messenger-8.2-handler-descriptor
Open

mstegmeyer wants to merge 1 commit into
DataDog:masterfrom
mstegmeyer:fix/symfony-messenger-8.2-handler-descriptor

Conversation

@mstegmeyer

Copy link
Copy Markdown
Contributor

Description

Symfony Messenger 8.2 changed HandleMessageMiddleware::callHandler() to take the HandlerDescriptor and the Envelope instead of the handler closure and the message (symfony/symfony v8.2.0). The integration hands $args[0] to install_hook(), so every handled message logs

TypeError thrown in ddtrace's closure defined at .../SymfonyMessengerIntegration.php:136 for Symfony\Component\Messenger\Middleware\HandleMessageMiddleware::callHandler(): DDTrace\install_hook(): Argument #1 ($target) must be of type string|callable|Generator|Closure, got Symfony\Component\Messenger\Handler\HandlerDescriptor

and the symfony.messenger.handle span is lost. The fix unwraps the descriptor's handler. The envelope now arriving as $args[1] already goes through setSpanAttributes(), which accepts an envelope or a message.

Checked with a minimal bus dispatching one message: on Messenger 8.2 the symfony.messenger.handle span is back and the warning is gone. On 8.1 the spans are unchanged. The Latest Symfony test app is still pinned to 8.0, so CI doesn't run against 8.2 yet.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

… 8.2

Symfony Messenger 8.2 changed HandleMessageMiddleware::callHandler() to take the HandlerDescriptor and the Envelope instead of the handler closure and the message. Passing the descriptor to install_hook() threw a TypeError on every handled message and the symfony.messenger.handle span was lost.
@mstegmeyer
mstegmeyer requested review from a team as code owners December 4, 2026 22:09
@mstegmeyer
mstegmeyer requested review from tabgok and removed request for a team December 4, 2026 22:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T22:12:55.372155Z 240b7c6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-3 datadog-prod-us1-3 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

The Messenger 8.2 descriptor now resolves to the handler callable expected by install_hook(), preserving the older callable path. Runtime compatibility remains unverified because the review environment lacks the ddtrace extension.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 240b7c6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant