Skip to content

fix(teams): pass channel_info/team_info to lifecycle handler dispatches#375

Open
btoo wants to merge 1 commit intomicrosoft:mainfrom
btoo:fix/teams-channel-lifecycle-dispatch-args
Open

fix(teams): pass channel_info/team_info to lifecycle handler dispatches#375
btoo wants to merge 1 commit intomicrosoft:mainfrom
btoo:fix/teams-channel-lifecycle-dispatch-args

Conversation

@btoo
Copy link
Copy Markdown

@btoo btoo commented Apr 21, 2026

The Teams handler's lifecycle dispatcher calls 10 channel/team event handlers with 1 arg, but every one of those methods needs 3. Sixteen lines above the same file dispatches members_added correctly, the file imports ChannelInfo only to type those signatures, and the .NET sibling does it the right way.

Anyone who installs an agents-for-python bot in a Teams team and then creates, renames, or deletes a channel gets a TypeError echoed into the channel by the default error handler. Shipped Aug 2025, untouched since.

Fix passes channel_data.channel and channel_data.team (already in scope) to all 10 dispatches.

The TeamsActivityHandler.on_conversation_update_activity dispatcher was
calling on_teams_channel_created/deleted/renamed/restored and
on_teams_team_archived/deleted/hardDeleted/renamed/restored/unarchived
with only turn_context, but every one of those methods is defined with
a 3-arg signature (channel_info, team_info, turn_context) or 2-arg
(team_info, turn_context).

Result: any Teams team where the bot is installed raises a TypeError
the moment a channel is created/renamed/etc., which the default
on_turn_error then echoes into the channel as a stack trace — visible
to all members.

The .NET sibling SDK (microsoft/Agents-for-net,
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams/Compat/TeamsActivityHandler.cs:504)
is the canonical reference and dispatches with all 3 args
(channelData.Channel, channelData.Team, turnContext).

The same dispatcher already extracts channel_data.team correctly for
on_teams_members_added_dispatch (line 513), so channel_data.channel
and channel_data.team are in scope at the call sites — this is purely
a transcription bug. No public API changes.
@btoo
Copy link
Copy Markdown
Author

btoo commented Apr 21, 2026

@microsoft-github-policy-service agree

@rodrigobr-msft
Copy link
Copy Markdown
Contributor

Make sure to run install the black formatter and run

black ./libraries ./tests

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.

2 participants