Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

The SDK was throwing validation errors when receiving signin/failure invoke activities because this invoke type was not defined in the activity model discriminated union.

Changes

  • Added SignInFailure model (packages/api/src/microsoft/teams/api/models/sign_in/failure.py)

    • Captures code and message from sign-in failures
  • Added SignInFailureInvokeActivity (packages/api/src/microsoft/teams/api/activities/invoke/sign_in/failure.py)

    • Handles signin/failure invoke type
    • Follows existing pattern for signin/tokenExchange and signin/verifyState
  • Updated SignInInvokeActivity discriminated union

    • Now includes SignInFailureInvokeActivity as a valid member

Example

Activities like this from the issue now parse successfully:

{
  "name": "signin/failure",
  "type": "invoke",
  "value": {
    "code": "resourcematchfailed",
    "message": "Resource match failed"
  },
  ...
}

Before: union_tag_invalid validation error
After: Activity parses correctly, error details available to handlers

Original prompt

This section details on the original issue you should resolve

<issue_title>SignIn failures are not handled gracefully.</issue_title>
<issue_description>When there is a sign in failure, the invoke says this. It looks like we're missing a signin/failure invoke type.

[ERROR] @teams/app.HttpPlugin [
[ERROR] @teams/app.HttpPlugin   {
[ERROR] @teams/app.HttpPlugin     "type": "union_tag_invalid",
[ERROR] @teams/app.HttpPlugin     "loc": [
[ERROR] @teams/app.HttpPlugin       "invoke"
[ERROR] @teams/app.HttpPlugin     ],
[ERROR] @teams/app.HttpPlugin     "msg": "Input tag 'signin/failure' 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', 'adaptiveCard/action'",
[ERROR] @teams/app.HttpPlugin     "input": {
[ERROR] @teams/app.HttpPlugin       "name": "signin/failure",
[ERROR] @teams/app.HttpPlugin       "type": "invoke",
[ERROR] @teams/app.HttpPlugin       "timestamp": "2025-11-05T22:22:17.758Z",
[ERROR] @teams/app.HttpPlugin       "localTimestamp": "2025-11-05T14:22:17.758-08:00",
[ERROR] @teams/app.HttpPlugin       "id": "f:1cb5a678-9635-e784-1f0b-dfab7bc0a9d0",
[ERROR] @teams/app.HttpPlugin       "channelId": "msteams",
[ERROR] @teams/app.HttpPlugin       "serviceUrl": "https://smba.trafficmanager.net/amer/56653e9d-2158-46ee-90d7-675c39642038/",
[ERROR] @teams/app.HttpPlugin       "from": {
[ERROR] @teams/app.HttpPlugin         "id": "29:1mucl7V-q79FxvutdFZYmoDU31kcD-H1rzq9likmczten5HjaAYvVz7buaSIHTJKxegI8mEBVYJt2BqJLkFQGBQ",
[ERROR] @teams/app.HttpPlugin         "name": "Aamir Jawaid",
[ERROR] @teams/app.HttpPlugin         "aadObjectId": "4816e27f-5665-4904-a182-f74d3bd509ac"
[ERROR] @teams/app.HttpPlugin       },
[ERROR] @teams/app.HttpPlugin       "conversation": {
[ERROR] @teams/app.HttpPlugin         "conversationType": "personal",
[ERROR] @teams/app.HttpPlugin         "tenantId": "56653e9d-2158-46ee-90d7-675c39642038",
[ERROR] @teams/app.HttpPlugin         "id": "a:12EDAH5_gp4Dl0X7cz84b4He6xkTE08HJs6EekON4_a6isW-pwyADo_9pj-9rDGWd0YlQ77hgMHkZe8laJ-RGzeA8i_C_RF--g73NwjUJe7cEIRQWr6n3NwACa__l54M4"
[ERROR] @teams/app.HttpPlugin       },
[ERROR] @teams/app.HttpPlugin       "recipient": {
[ERROR] @teams/app.HttpPlugin         "id": "28:8435f2a2-aa2c-4e6a-885f-d21469cbb09b",
[ERROR] @teams/app.HttpPlugin         "name": "aamirtesterfic"
[ERROR] @teams/app.HttpPlugin       },
[ERROR] @teams/app.HttpPlugin       "entities": [
[ERROR] @teams/app.HttpPlugin         {
[ERROR] @teams/app.HttpPlugin           "locale": "en-US",
[ERROR] @teams/app.HttpPlugin           "country": "US",
[ERROR] @teams/app.HttpPlugin           "platform": "Web",
[ERROR] @teams/app.HttpPlugin           "timezone": "America/Los_Angeles",
[ERROR] @teams/app.HttpPlugin           "type": "clientInfo"
[ERROR] @teams/app.HttpPlugin         }
[ERROR] @teams/app.HttpPlugin       ],
[ERROR] @teams/app.HttpPlugin       "channelData": {
[ERROR] @teams/app.HttpPlugin         "tenant": {
[ERROR] @teams/app.HttpPlugin           "id": "56653e9d-2158-46ee-90d7-675c39642038"
[ERROR] @teams/app.HttpPlugin         },
[ERROR] @teams/app.HttpPlugin         "source": {
[ERROR] @teams/app.HttpPlugin           "name": "message"
[ERROR] @teams/app.HttpPlugin         }
[ERROR] @teams/app.HttpPlugin       },
[ERROR] @teams/app.HttpPlugin       "value": {
[ERROR] @teams/app.HttpPlugin         "code": "resourcematchfailed",
[ERROR] @teams/app.HttpPlugin         "message": "Resource match failed"
[ERROR] @teams/app.HttpPlugin       },
[ERROR] @teams/app.HttpPlugin       "locale": "en-US",
[ERROR] @teams/app.HttpPlugin       "localTimezone": "America/Los_Angeles"
[ERROR] @teams/app.HttpPlugin     },
[ERROR] @teams/app.HttpPlugin     "ctx": {
[ERROR] @teams/app.HttpPlugin       "discriminator": "'name'",
[ERROR] @teams/app.HttpPlugin       "tag": "signin/failure",
[ERROR] @teams/app.HttpPlugin       "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', 'adaptiveCard/action'"
[ERROR] @teams/app.HttpPlugin     },
[ERROR] @teams/app.HttpPlugin     "url"...

</details>

- Fixes microsoft/teams.py#205

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI changed the title [WIP] Fix sign in failures handling in invoke Add signin/failure invoke activity support Nov 6, 2025
Copilot AI requested a review from heyitsaamir November 6, 2025 02:47
Copilot finished work on behalf of heyitsaamir November 6, 2025 02:47
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.

2 participants