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

Fix Middleware Chain to Allow Awaiting Final Logic Result #2213

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gandiddi
Copy link
Collaborator

Fixes #2197

Description

Previously, the middleware chain executed each handler sequentially, but none could await the final logic result. This prevented middlewares from processing the response of the last middleware (which runs the actual logic).

This PR updates the TurnContext class in the botbuilder-core library to modify the middleware chain handling. The changes ensure that middleware can await the result of the "next" middleware, including the final logic.
This allows for more flexible and powerful middleware handling.

Specific Changes

1. TurnContext Class:

  • Modified the _emit method to ensure that each middleware can await the result of the next middleware in the chain, including the final logic.
  • Updated the _emit method to return the result of the logic coroutine correctly.

2. Test Cases:

  • Updated the test_update_activity_should_apply_conversation_reference test case to handle the ResourceResponse correctly and ensure the update_activity method returns the correct ResourceResponse.

@gandiddi gandiddi requested a review from a team as a code owner March 12, 2025 14:50
@gandiddi gandiddi requested a review from tracyboehrer March 12, 2025 15:28
@tracyboehrer tracyboehrer requested review from axelsrz and removed request for tracyboehrer March 25, 2025 17:24
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.

Middleware logic in turncontext emit is broken
1 participant