Skip to content
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

[Messenger] Don't drop stamps when message validation fails #54842

Merged
merged 1 commit into from
May 7, 2024

Conversation

valtzu
Copy link
Contributor

@valtzu valtzu commented May 4, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

ValidationMiddleware has the same issue as DispatchAfterCurrentBusMiddleware did before the fix: if message validation fails, stamps added by previous middlewares in the stack are dropped. What this means in practice is:

  1. bin/console messenger:consume --bus=external receives a message and AddBusNameStampMiddleware adds the BusNameStamp so that in case of failure it would be routed to a correct bus
  2. The message fails validation – the original envelope without the added BusNameStamp is sent to failure queue
  3. When running bin/console messenger:failed:retry, the message is dispatched on wrong bus (the default one)

This has really bad implications if you handle the message differently depending on which bus it is received.

Some refactoring was done to reduce duplication, similar to WrappedExceptionsTrait/WrappedExceptionsInterface.

@fabpot fabpot force-pushed the fix-messenger-validation-stamps branch from f51aa95 to fed32dc Compare May 7, 2024 06:17
@fabpot
Copy link
Member

fabpot commented May 7, 2024

Thank you @valtzu.

@fabpot fabpot merged commit 3de527c into symfony:6.4 May 7, 2024
4 of 7 checks passed
@fabpot
Copy link
Member

fabpot commented May 7, 2024

@valtzu I've merged this PR up to 7.1. Can you submit a PR on 7.1 to remove the @internal tag?

fabpot added a commit that referenced this pull request May 7, 2024
…e` internal (valtzu)

This PR was merged into the 7.1 branch.

Discussion
----------

[Messenger] Don't mark `EnvelopeAwareExceptionInterface` internal

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| License       | MIT

As discussed [here](#54842 (comment)), let's expose `EnvelopeAwareExceptionInterface` to allow custom Messenger middlewares throw a custom exception without causing stamps from previous middlewares being dropped.

Commits
-------

7713fd1 Don't mark EnvelopeAwareExceptionInterface internal
symfony-splitter pushed a commit to symfony/messenger that referenced this pull request May 7, 2024
…e` internal (valtzu)

This PR was merged into the 7.1 branch.

Discussion
----------

[Messenger] Don't mark `EnvelopeAwareExceptionInterface` internal

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| License       | MIT

As discussed [here](symfony/symfony#54842 (comment)), let's expose `EnvelopeAwareExceptionInterface` to allow custom Messenger middlewares throw a custom exception without causing stamps from previous middlewares being dropped.

Commits
-------

7713fd17f5 Don't mark EnvelopeAwareExceptionInterface internal
@fabpot fabpot mentioned this pull request May 17, 2024
This was referenced Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants