microsoft / microsoft/teams.py
Route priority: specific handlers should run before global/fallback handlers
- Dominant language
- Python
- Stars
- 65
- Forks
- 30
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 23
Description
## Problem
Handlers run in registration order. When a broad handler is registered before a specific one, the broad handler runs first and the specific handler never fires. This affects multiple handler levels:
- `@app.on_card_action_execute` (global) swallows `@app.on_card_action_execute("submit_feedback")` (specific)
- `@app.on_dialog_open` (global) swallows `@app.on_dialog_open("my_form")` (specific)
- `@app.on_dialog_submit` (global) swallows `@app.on_dialog_submit("save")` (specific)
- `@app.on_invoke` swallows all specific invoke handlers (`on_dialog_open`, `on_card_action_execute`, etc.)
- `@app.on_event` swallows `on_meeting_start`, `on_read_receipt`, etc.
- `@app.on_conversation_update` swallows `on_channel_created`, `on_team_renamed`, etc.
- `@app.on_message_update` swallows `on_edit_message`, `on_undelete_message`
- `@app.on_message_delete` swallows `on_soft_delete_message`
- `@app.on_installation_update` swallows `on_install_add`, `on_install_remove`
- `@app.on_activity` swallows everything
Users shouldn't have to worry about registration order.
## Expected behavior
The router should prioritize more specific selectors over broader ones when multiple handlers match the same activity, regardless of registration order.
Contributor guide
Research direction
Start at the router that dispatches registered handlers and trace how registration order determines the first matching handler. Reproduce the listed global-versus-specific cases, then verify that specific selectors win across each handler level regardless of registration order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100