Skip to content

Don't require selectedChannel when deserializing channel data - #655

Merged
Corina (corinagum) merged 1 commit into
mainfrom
cg/fix/empty-inbound-objects
Aug 18, 2026
Merged

Don't require selectedChannel when deserializing channel data#655
Corina (corinagum) merged 1 commit into
mainfrom
cg/fix/empty-inbound-objects

Conversation

@corinagum

Copy link
Copy Markdown
Collaborator

TeamsChannelDataSettings.SelectedChannel was declared required, and System.Text.Json enforces required members (.NET 7+). A channelData.settings of {} therefore threw:

JsonException: JSON deserialization for type 'Settings' was missing required properties including: 'selectedChannel'.

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, but SelectedChannel was the one strict field and would fail the same way.

This is latent rather than actively reported: settings appears less often than app. Fixing it now avoids the same class of outage.

Change

 public required TeamsChannel SelectedChannel  > public TeamsChannel? SelectedChannel

Inbound models shouldn't enforce required fields on service-provided data. No consumers of SelectedChannel exist in  src/, test/, or Samples/ .

Tests

New TeamsChannelDataDeserializationTests.cs empty app / channel / team / tenant / settings  all deserialize,  SelectedChannel  is null for empty settings, and populated values round-trip.

Validation

  • Build: 0 warnings, 0 errors
  • 522 tests pass (net10.0)
  • No net new format issues

Copilot AI lite review requested due to automatic review settings August 17, 2026 19:50
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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

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.SelectedChannel from required TeamsChannel to nullable TeamsChannel? to allow empty settings objects.
  • 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.

@singhk97 Kavin (singhk97) 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.

nice proactive fix. can you elaborate on the scenario where this field is omitted

@corinagum
Corina (corinagum) added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 2f67323 Aug 18, 2026
7 checks passed
@corinagum
Corina (corinagum) deleted the cg/fix/empty-inbound-objects branch August 18, 2026 17:08
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.

3 participants