Skip to content

Allow unknown activity entities and missing channelData#438

Merged
lilyydu merged 6 commits into
microsoft:mainfrom
dcaayushd:fix/unknown-entity-fallback
Jun 1, 2026
Merged

Allow unknown activity entities and missing channelData#438
lilyydu merged 6 commits into
microsoft:mainfrom
dcaayushd:fix/unknown-entity-fallback

Conversation

@dcaayushd

@dcaayushd dcaayushd commented May 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #433

What changed

  • Add a fallback UnknownEntity so new entity types do not break activity parsing
  • Make conversationUpdate channelData optional to avoid 500s on missing data
  • Add tests for unknown entities and missing channelData

Why

Real Bot Framework traffic can include new entity types and sometimes skips channelData. These should not block message handling.

Tests

  • PYTHONPATH=packages/api/src:packages/common/src:packages/cards/src /Users/dcaayushd/Development/OpenSourceContribution/teams.py/venv/bin/python -m pytest packages/api/tests/unit/test_activity.py -k ActivityTypeAdapter
  • PYTHONPATH=packages/api/src:packages/common/src:packages/cards/src /Users/dcaayushd/Development/OpenSourceContribution/teams.py/venv/bin/python -m pytest packages/api/tests/unit/test_activity.py

Copilot AI review requested due to automatic review settings May 23, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds forward-compatible handling for unknown activity entity types and relaxes conversationUpdate parsing when channelData is absent.

Changes:

  • Introduces UnknownEntity and includes it in the Entity union / exports.
  • Updates ConversationUpdateActivity.channel_data to be optional with a default of None.
  • Adds unit tests validating ActivityTypeAdapter behavior for unknown entities and missing channelData.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/api/tests/unit/test_activity.py Adds unit coverage for unknown entity passthrough and optional channel_data on conversation updates.
packages/api/src/microsoft_teams/api/models/entity/unknown_entity.py Introduces a new model type intended to capture unknown/forward-compatible entities.
packages/api/src/microsoft_teams/api/models/entity/entity.py Adds UnknownEntity into the Entity union for parsing.
packages/api/src/microsoft_teams/api/models/entity/init.py Exposes UnknownEntity as part of the public entity API.
packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.py Makes channel_data optional to support payloads without channelData.

Comment thread packages/api/src/microsoft_teams/api/models/entity/unknown_entity.py Outdated
Comment thread packages/api/src/microsoft_teams/api/models/entity/unknown_entity.py Outdated
@mjamroz

mjamroz commented May 25, 2026

Copy link
Copy Markdown
Contributor

@mjamroz Could you please review this PR and approve the workflow when you have a chance? Thanks!

Hey @dcaayushd i believe it's some mistake, im not Microsoft staff neither related with teams.py

@dcaayushd

Copy link
Copy Markdown
Contributor Author

Sorry about the wrong tag! I'll find the right maintainer to review this.

@dcaayushd

Copy link
Copy Markdown
Contributor Author

@lilyydu @corinagum Could you please review this PR and approve the workflow when you have a chance? Thanks!

@lilyydu

lilyydu commented May 26, 2026

Copy link
Copy Markdown
Collaborator

@lilyydu @corinagum Could you please review this PR and approve the workflow when you have a chance? Thanks!

Hey! Thanks for raising this fix - this requires a deeper discussion with our team. Will follow back when we reach a conclusion!

@lilyydu

lilyydu commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Hi @dcaayushd,

Upon discussion, it is correct that Python should not be marking channelData as required. In both TS and .NET, this is a nullable property.

And likewise for unknown entity types, this should not throw an error.

Will leave review comments for fixes :)

Comment thread packages/api/src/microsoft_teams/api/models/entity/unknown_entity.py Outdated
Comment thread packages/api/tests/unit/test_activity.py Outdated
Comment thread packages/api/src/microsoft_teams/api/models/entity/unknown_entity.py Outdated

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall this looks good. I think for the unknown entity type, I'd prefer introducing a fallback UnknownEntity instead though. Curious if you had a different idea.

Comment thread packages/api/src/microsoft_teams/api/models/entity/entity.py Outdated
Comment thread packages/api/src/microsoft_teams/api/models/entity/entity_base.py Outdated

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lgtm. Thanks for the contribution!

@dcaayushd

Copy link
Copy Markdown
Contributor Author

hey @lilyydu, this one's been approved by @heyitsaamir but needs a second review due to branch protection since he was the last to push. would you mind taking a look when you get a chance? thanks!

@lilyydu
lilyydu merged commit fbbe671 into microsoft:main Jun 1, 2026
4 checks passed
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.

[Bug]: Activity validation fails on unknown entity types; strict tagged union rejects entire activity instead of ignoring unknown entities

5 participants