Skip to content

Conversation

@rajan-chari
Copy link
Contributor

Fixes #239

Summary

Make channel_data optional in ConversationUpdateActivity to support Direct Line API 3.0, which sends conversationUpdate activities without the channelData field. This fixes validation errors when receiving messages from Direct Line.

Problem

When using Direct Line API 3.0 with the Teams SDK for Python, Direct Line automatically sends conversationUpdate activities without channelData when starting a conversation. The Teams SDK required this field, causing Pydantic validation errors:

Field required [type=missing, input_value={'type': 'conversationUpdate'...}]

Changes

  1. Made channel_data optional in ConversationUpdateActivity - Removed the required field override, allowing it to inherit the optional definition from the base class
  2. Updated activity route selectors - Added null checks (activity.channel_data is not None) before accessing event_type in 13 selectors to prevent AttributeError
  3. Added comprehensive test coverage - 8 new tests covering Direct Line scenarios

Test Results

  • ✅ All 236 tests pass (8 new tests added)
  • ✅ Existing functionality preserved (Teams with channelData still works)
  • ✅ Direct Line compatibility achieved (activities without channelData now accepted)

Files Changed

  • packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.py
  • packages/apps/src/microsoft_teams/apps/routing/activity_route_configs.py
  • packages/api/tests/unit/test_conversation_update_directline.py (new)
  • packages/apps/tests/test_conversation_update_routing.py (new)

🤖 Generated with Claude Code

Make channel_data optional in ConversationUpdateActivity to support Direct Line API 3.0, which sends conversationUpdate activities without channelData field. This fixes validation errors when receiving messages from Direct Line.

Changes:
- Remove required channel_data field override in ConversationUpdateActivity
- Add null checks in activity route selectors before accessing channel_data.event_type
- Add comprehensive tests for Direct Line compatibility (8 new tests)
- All tests pass (236 total, up from 228)

Test Coverage:
- ConversationUpdateActivity parsing without channelData (Direct Line scenario)
- ConversationUpdateActivity parsing with channelData (Teams scenario)
- Activity routing with and without channelData
- All event-specific selectors handle None channelData gracefully

Fixes #239

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 15, 2026 17:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where Direct Line API 3.0 sends conversationUpdate activities without the channelData field, causing validation errors in the Teams SDK for Python. The fix makes channel_data optional in ConversationUpdateActivity and adds null-safety checks to activity route selectors.

Changes:

  • Made channel_data optional in ConversationUpdateActivity by removing the required field override
  • Added null checks to 13 activity route selectors before accessing event_type property
  • Added comprehensive test coverage with 8 new tests for Direct Line compatibility

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.py Removed required override for channel_data, making it optional by inheriting from base class
packages/apps/src/microsoft_teams/apps/routing/activity_route_configs.py Added null checks to selectors for message and conversation event types to prevent AttributeError
packages/api/tests/unit/test_conversation_update_directline.py New test file with 3 tests verifying Direct Line compatibility and parsing behavior
packages/apps/tests/test_conversation_update_routing.py New test file with 5 tests verifying routing behavior with and without channel_data

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.

Validation fails when receiving a message from Direct Line - missing conversationUpdate.channelData

2 participants