Don't require selectedChannel when deserializing channel data - #655
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes required from TeamsChannelDataSettings.SelectedChannel to prevent System.Text.Json from throwing when the Teams service provides channelData.settings (and similar nested objects) as {}. This aligns the inbound schema with real-world service payloads and avoids deserialization outages on newer runtimes that enforce required members.
Changes:
- Relax
TeamsChannelDataSettings.SelectedChannelfromrequired TeamsChannelto nullableTeamsChannel?to allow emptysettingsobjects. - Add unit tests covering empty nested channelData objects (
app,channel,team,tenant,settings) and ensuring populated values deserialize correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Microsoft.Teams.Apps.UnitTests/TeamsChannelDataDeserializationTests.cs | Adds deserialization regression coverage for empty nested channelData objects and verifies SelectedChannel null/preserved behavior. |
| src/Microsoft.Teams.Apps/Schema/TeamsChannelData.cs | Makes SelectedChannel nullable to avoid required-member deserialization failures for service-provided {} payloads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Kavin (singhk97)
approved these changes
Aug 18, 2026
Kavin (singhk97)
left a comment
Collaborator
There was a problem hiding this comment.
nice proactive fix. can you elaborate on the scenario where this field is omitted
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.
TeamsChannelDataSettings.SelectedChannelwas declaredrequired, andSystem.Text.Jsonenforcesrequiredmembers (.NET 7+). AchannelData.settingsof{}therefore threw:Found while investigating teams.py#563, where the Teams service sent
channelData.app as {}. .NET was otherwise unaffected; every other channel-data property is already nullable, butSelectedChannelwas the one strict field and would fail the same way.This is latent rather than actively reported:
settingsappears less often thanapp. Fixing it now avoids the same class of outage.Change
public required TeamsChannel SelectedChannel>public TeamsChannel? SelectedChannelInbound models shouldn't enforce required fields on service-provided data. No consumers of
SelectedChannelexist insrc/,test/, orSamples/.Tests
New
TeamsChannelDataDeserializationTests.csemptyapp/channel/team/tenant/settingsall deserialize,SelectedChannelis null for empty settings, and populated values round-trip.Validation