Skip to content

Fix choices_data alias to use "choices.data" instead of "choicesData"#224

Merged
heyitsaamir merged 2 commits into
mainfrom
copilot/update-choices-data-alias
Nov 26, 2025
Merged

Fix choices_data alias to use "choices.data" instead of "choicesData"#224
heyitsaamir merged 2 commits into
mainfrom
copilot/update-choices-data-alias

Conversation

Copilot AI commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

The choices_data field in ChoiceSetInput was incorrectly serializing to "choicesData" (default camelCase) instead of "choices.data" per the Adaptive Cards spec.

Changes

  • Added special case handling in SerializableObject.validation_alias_generator and serialization_alias_generator for choices_data"choices.data"
  • Added test for serialization/deserialization round-trip

Example

from microsoft.teams.cards import ChoiceSetInput, QueryData

choice_set = ChoiceSetInput(id="myChoices", choices_data=QueryData(dataset="my_dataset"))
json_str = choice_set.model_dump_json(exclude_none=True, by_alias=True)

# Before: {"id": "myChoices", "choicesData": {...}}
# After:  {"id": "myChoices", "choices.data": {...}}

Follows existing pattern for ms_teams"msteams".

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • login.microsoftonline.com
    • Triggering command: /home/REDACTED/work/teams.py/teams.py/.venv/bin/pytest pytest packages -x (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

in Cards package, choices_data needs to use the alias "choices.data" instead "choiceData" like it currently does.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update alias for choices_data in Cards package Fix choices_data alias to use "choices.data" instead of "choicesData" Nov 24, 2025
Copilot AI requested a review from heyitsaamir November 24, 2025 23:24
@heyitsaamir
heyitsaamir marked this pull request as ready for review November 24, 2025 23:31
Copilot AI review requested due to automatic review settings November 24, 2025 23:31

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 fixes the serialization alias for the choices_data field in ChoiceSetInput to use "choices.data" instead of the default camelCase "choicesData", ensuring compliance with the Adaptive Cards specification.

Key changes:

  • Added special case handling for choices_data"choices.data" in both validation and serialization alias generators
  • Added comprehensive test coverage for serialization and deserialization round-trip

Reviewed changes

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

File Description
packages/cards/src/microsoft/teams/cards/core.py Added special alias handling for choices_data field in both validation_alias_generator and serialization_alias_generator methods, following the existing pattern used for ms_teams
packages/cards/tests/test_core_serialization.py Added test test_choices_data_serializes_to_choices_dot_data() to verify proper serialization to "choices.data" and deserialization round-trip, plus imported necessary types

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@heyitsaamir

Copy link
Copy Markdown
Collaborator
image

@aviadpriel

Copy link
Copy Markdown

when is the plan to merge it ?

@aviadpriel

aviadpriel commented Nov 26, 2025

Copy link
Copy Markdown

@heyitsaamir this will still fail on search with dataset that come form the app

Because the app not support yeat 'application/search

when i added the missing types is work well 🚀

we can extend the on_invoke event
and add on_invoke_search that allow to fillter by dataset etc

pydantic_core._pydantic_core.ValidationError: 1 validation error for tagged-union[HandoffActivity,TraceActivity,TypingActivity,CommandSendActivity,CommandResultActivity,ConversationUpdateActivity,EndOfConversationActivity,MessageActivity,MessageDeleteActivity,MessageReactionActivity,MessageUpdateActivity,tagged-union[ReadReceiptEventActivity,MeetingStartEventActivity,MeetingEndEventActivity,MeetingParticipantJoinEventActivity,MeetingParticipantLeaveEventActivity],tagged-union[FileConsentInvokeActivity,ExecuteActionInvokeActivity,MessageExtensionAnonQueryLinkInvokeActivity,MessageExtensionCardButtonClickedInvokeActivity,MessageExtensionFetchTaskInvokeActivity,MessageExtensionQueryInvokeActivity,MessageExtensionQueryLinkInvokeActivity,MessageExtensionQuerySettingUrlInvokeActivity,MessageExtensionSelectItemInvokeActivity,MessageExtensionSettingInvokeActivity,MessageExtensionSubmitActionInvokeActivity,ConfigFetchInvokeActivity,ConfigSubmitInvokeActivity,TabFetchInvokeActivity,TabSubmitInvokeActivity,TaskFetchInvokeActivity,TaskSubmitInvokeActivity,MessageSubmitActionInvokeActivity,HandoffActionInvokeActivity,SignInTokenExchangeInvokeActivity,SignInVerifyStateInvokeActivity,SignInFailureInvokeActivity,AdaptiveCardInvokeActivity],tagged-union[InstalledActivity,UninstalledActivity]]
invoke
  Input tag 'application/search' found using 'name' does not match any of the expected tags: 'fileConsent/invoke', 'actionableMessage/executeAction', 'composeExtension/anonymousQueryLink', 'composeExtension/onCardButtonClicked', 'composeExtension/fetchTask', 'composeExtension/query', 'composeExtension/queryLink', 'composeExtension/querySettingUrl', 'composeExtension/selectItem', 'composeExtension/setting', 'composeExtension/submitAction', 'config/fetch', 'config/submit', 'tab/fetch', 'tab/submit', 'task/fetch', 'task/submit', 'message/submitAction', 'handoff/action', 'signin/tokenExchange', 'signin/verifyState', 'signin/failure', 'adaptiveCard/action' [type=union_tag_invalid, input_value={'name': 'application/sea...zone': 'Asia/Jerusalem'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/union_tag_invalid

@heyitsaamir

Copy link
Copy Markdown
Collaborator

@heyitsaamir this will still fail on search with dataset that come form the app

Because the app not support yeat 'application/search

when i added the missing types is work well 🚀

we can extend the on_invoke event and add on_invoke_search that allow to fillter by dataset etc

pydantic_core._pydantic_core.ValidationError: 1 validation error for tagged-union[HandoffActivity,TraceActivity,TypingActivity,CommandSendActivity,CommandResultActivity,ConversationUpdateActivity,EndOfConversationActivity,MessageActivity,MessageDeleteActivity,MessageReactionActivity,MessageUpdateActivity,tagged-union[ReadReceiptEventActivity,MeetingStartEventActivity,MeetingEndEventActivity,MeetingParticipantJoinEventActivity,MeetingParticipantLeaveEventActivity],tagged-union[FileConsentInvokeActivity,ExecuteActionInvokeActivity,MessageExtensionAnonQueryLinkInvokeActivity,MessageExtensionCardButtonClickedInvokeActivity,MessageExtensionFetchTaskInvokeActivity,MessageExtensionQueryInvokeActivity,MessageExtensionQueryLinkInvokeActivity,MessageExtensionQuerySettingUrlInvokeActivity,MessageExtensionSelectItemInvokeActivity,MessageExtensionSettingInvokeActivity,MessageExtensionSubmitActionInvokeActivity,ConfigFetchInvokeActivity,ConfigSubmitInvokeActivity,TabFetchInvokeActivity,TabSubmitInvokeActivity,TaskFetchInvokeActivity,TaskSubmitInvokeActivity,MessageSubmitActionInvokeActivity,HandoffActionInvokeActivity,SignInTokenExchangeInvokeActivity,SignInVerifyStateInvokeActivity,SignInFailureInvokeActivity,AdaptiveCardInvokeActivity],tagged-union[InstalledActivity,UninstalledActivity]]
invoke
  Input tag 'application/search' found using 'name' does not match any of the expected tags: 'fileConsent/invoke', 'actionableMessage/executeAction', 'composeExtension/anonymousQueryLink', 'composeExtension/onCardButtonClicked', 'composeExtension/fetchTask', 'composeExtension/query', 'composeExtension/queryLink', 'composeExtension/querySettingUrl', 'composeExtension/selectItem', 'composeExtension/setting', 'composeExtension/submitAction', 'config/fetch', 'config/submit', 'tab/fetch', 'tab/submit', 'task/fetch', 'task/submit', 'message/submitAction', 'handoff/action', 'signin/tokenExchange', 'signin/verifyState', 'signin/failure', 'adaptiveCard/action' [type=union_tag_invalid, input_value={'name': 'application/sea...zone': 'Asia/Jerusalem'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/union_tag_invalid

Thanks @aviadpriel ! Would you mind putting up a PR with that?

@aacebo iirc you had added this somewhere right?

@heyitsaamir
heyitsaamir merged commit ae371c5 into main Nov 26, 2025
14 checks passed
@heyitsaamir
heyitsaamir deleted the copilot/update-choices-data-alias branch November 26, 2025 22:40
@heyitsaamir heyitsaamir mentioned this pull request Dec 9, 2025
heyitsaamir added a commit that referenced this pull request Dec 9, 2025
## Release 2.0.0a7

### Changes

- update react and react-dom to 19.2.1 (#233)
- Move to microsoft_teams namespace (#226)
- Simplify setting http response after activity processing  (#218)
- Add TeamsChannelAccount type for Teams-specific APIs (#230)
- Updating mcpplugin reference in README.md (#229)
- Bring back bot builder example (#225)
- Fix choices_data alias to use "choices.data" instead of "choicesData"
(#224)
- [docs] botbuilder package README fixes (#223)
- Fix calling AI functions with no parameters (#221)
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.

5 participants