Skip to content

[Bug] TeamsActivityHandler channel/team event dispatchers call handlers with wrong number of arguments (TypeError on channelCreated and related events) #449

Description

@DhavalBavda

Summary

TeamsActivityHandler.on_conversation_update_activity() dispatches all channel and
team conversationUpdate events by calling the handler with only turn_context, but
the base method signatures for those handlers declare extra required positional
parameters (channel_info, team_info). This causes a TypeError crash on any
Teams channel or team management event.

SDK Version

microsoft-agents-hosting==1.1.0
microsoft-agents-activity==1.1.0

Steps to Reproduce

  1. Install a bot built on TeamsActivityHandler into a Microsoft Teams team.
  2. Create a new channel in that team (or rename/delete/archive a channel, or
    rename/archive/delete the team itself).
  3. Teams sends a conversationUpdate activity with channelData.eventType = "channelCreated" (or any of the other event types below) to the bot endpoint.
  4. The bot crashes with TypeError.

Error

TypeError: TeamsActivityHandler.on_teams_channel_created() missing 2 required
positional arguments: 'team_info' and 'turn_context'

Full traceback:

File "microsoft_agents/hosting/core/channel_adapter.py", line 244, in run_pipeline
  return await self.middleware_set.receive_activity_with_status(...)
File "microsoft_agents/hosting/teams/teams_activity_handler.py", line 529, in on_conversation_update_activity
  return await self.on_teams_channel_created(turn_context)
TypeError: TeamsActivityHandler.on_teams_channel_created() missing 2 required
positional arguments: 'team_info' and 'turn_context'

Root Cause

The dispatcher in on_conversation_update_activity() calls all channel/team handlers
with a single argument:

# teams_activity_handler.py line 529
return await self.on_teams_channel_created(turn_context)

But the method definitions declare extra required positional parameters:

# teams_activity_handler.py line 721
async def on_teams_channel_created(
    self, channel_info: ChannelInfo, team_info: TeamInfo, turn_context: TurnContext
) -> None:

All Affected Handlers

Handler Caller passes Method expects
on_teams_channel_created (turn_context) (channel_info, team_info, turn_context)
on_teams_channel_deleted (turn_context) (channel_info, team_info, turn_context)
on_teams_channel_renamed (turn_context) (channel_info, team_info, turn_context)
on_teams_channel_restored (turn_context) (channel_info, team_info, turn_context)
on_teams_team_archived (turn_context) (team_info, turn_context)
on_teams_team_deleted (turn_context) (team_info, turn_context)
on_teams_team_hard_deleted (turn_context) (team_info, turn_context)
on_teams_team_renamed (turn_context) (team_info, turn_context)
on_teams_team_restored (turn_context) (team_info, turn_context)
on_teams_team_unarchived (turn_context) (team_info, turn_context)

Expected Fix

Either:

Option A — Fix the dispatcher to extract and pass channel_info/team_info
from turn_context.activity.channel_data before calling the handler (matching
what botbuilder-python did):

if event_type == "channelCreated":
    channel_info = ChannelInfo(...)   # extracted from channel_data
    team_info = TeamInfo(...)         # extracted from channel_data
    return await self.on_teams_channel_created(channel_info, team_info, turn_context)

Option B — Fix the method signatures to match what the dispatcher actually
passes (i.e. accept only turn_context and let implementors extract
channel_info/team_info themselves from turn_context.activity.channel_data).

Option A is preferred for backward compatibility with botbuilder-python subclasses.

Workaround

Until fixed, monkey-patch the base class in application startup code to override
all affected methods with signatures that match what the dispatcher actually calls:

from microsoft_agents.hosting.teams import TeamsActivityHandler

async def _noop_channel_event(self, turn_context) -> None:
    return

async def _noop_team_event(self, turn_context) -> None:
    return

TeamsActivityHandler.on_teams_channel_created   = _noop_channel_event
TeamsActivityHandler.on_teams_channel_deleted   = _noop_channel_event
TeamsActivityHandler.on_teams_channel_renamed   = _noop_channel_event
TeamsActivityHandler.on_teams_channel_restored  = _noop_channel_event
TeamsActivityHandler.on_teams_team_archived     = _noop_team_event
TeamsActivityHandler.on_teams_team_deleted      = _noop_team_event
TeamsActivityHandler.on_teams_team_hard_deleted = _noop_team_event
TeamsActivityHandler.on_teams_team_renamed      = _noop_team_event
TeamsActivityHandler.on_teams_team_restored     = _noop_team_event
TeamsActivityHandler.on_teams_team_unarchived   = _noop_team_event

Metadata

Metadata

Labels

BugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions