Make channelData subfields optional to avoid throw - #564
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression where inbound Activities could be rejected entirely due to ValidationError when Microsoft Teams sends certain nested objects as empty {} (notably under channelData, plus empty attachments / entities). It relaxes several model fields so inbound parsing degrades gracefully instead of dropping the activity, and adds targeted unit tests to lock in the behavior (fixing #563).
Changes:
- Relaxed several
channelData-related nested model fields to be optional so empty{}no longer fails validation (AppInfo.id,ChannelInfo.id,TeamInfo.id,TenantInfo.id,ChannelDataSettings.selected_channel). - Relaxed
Attachment.content_typeandEntityBase.typeto be optional so empty attachment/entity objects and forward-compatible entity types can parse. - Added new unit tests covering the empty-object cases and a future/unknown entity type.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/api/tests/unit/test_empty_inbound_objects.py | Adds regression tests for empty nested inbound objects and unknown entity types. |
| packages/api/src/microsoft_teams/api/models/entity/entity_base.py | Makes base entity type optional to allow unknown/empty entities to parse. |
| packages/api/src/microsoft_teams/api/models/channel_data/tenant_info.py | Makes TenantInfo.id optional to tolerate empty tenant objects. |
| packages/api/src/microsoft_teams/api/models/channel_data/team_info.py | Makes TeamInfo.id optional to tolerate empty team objects. |
| packages/api/src/microsoft_teams/api/models/channel_data/settings.py | Makes selected_channel optional to tolerate empty settings objects. |
| packages/api/src/microsoft_teams/api/models/channel_data/channel_info.py | Makes ChannelInfo.id optional to tolerate empty channel objects. |
| packages/api/src/microsoft_teams/api/models/channel_data/app_info.py | Makes AppInfo.id optional to tolerate empty app objects. |
| packages/api/src/microsoft_teams/api/models/attachment/attachment.py | Makes Attachment.content_type optional to tolerate empty attachment objects. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Mehak Bindra (MehakBindra)
approved these changes
Aug 18, 2026
This was referenced Aug 19, 2026
Corina (corinagum)
added a commit
that referenced
this pull request
Aug 19, 2026
Release 2.0.16: backport channelData optional-subfield fix (#564)
Corina (corinagum)
added a commit
that referenced
this pull request
Aug 19, 2026
Port channelData optional-subfield fix (#564) to 2.1 (2.1.0-alpha.2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #563
The Teams service can send nested
channelDataobjects as empty objects ({}). BecauseAppInfo.idwas required, Pydantic raised aValidationError, and sinceActivityTypeAdapter.validate_pythonhas no fallback, the entire activity was rejected, so affected bots silently stopped responding.Reported against 2.0.15, the first release containing #504. Confirmed to affect customers, currently in 1:1 chats, with exposure growing as an upstream server-side rollout ramps.
Root cause
channelData.appis optional, so an absentappwas always fine, but a present but empty one wasn't. Auditing the model graph showed this isn't unique toapp: 98 sites exist where an optional parent points at a child with required fields. Seven were reachable from a plain message activity:Change
Make these inbound-only fields optional:
AppInfo.id,ChannelInfo.id,TeamInfo.id,TenantInfo.id,ChannelDataSettings.selected_channel,Attachment.content_type,EntityBase.type.MessageUpdateChannelDataandMessageDeleteChannelDataboth inheritChannelData, so they're covered without separate edits.EntityBase.typeis relaxed at the base rather than overridden onUnknownEntity: every concrete entity already overridestypewith aLiteraldefault, soUnknownEntityis the only class inheriting it raw. This also means an entity type introduced after this SDK version no longer drops the message.Tests
New
test_empty_inbound_objects.pycovering each empty-object case, an unrecognized entity type, that populated values still parse, and that absentchannelDatais unchanged.Validation
packages/api+packages/appsruff format/ruff checkcleanNotes
This is the defensive half. The empty object is a service-side wire-contract issue and has been raised with that team separately; this change means the SDK degrades gracefully regardless.