Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Add signin/failure Activity Support ✓

Successfully resolved the issue where signin/failure invoke activities were causing validation errors.

Fixes #205

Problem

When sign-in failures occurred, the system threw a validation error:

union_tag_invalid: Input tag 'signin/failure' found using 'name' does not match any of the expected tags

Solution

Added complete support for the signin/failure invoke activity type in the API package.

Changes Made

  1. Created SignInFailure model (packages/api/src/microsoft/teams/api/models/sign_in/failure.py)

    • Contains code and message fields to capture failure details
  2. Created SignInFailureInvokeActivity (packages/api/src/microsoft/teams/api/activities/invoke/sign_in/failure.py)

    • New invoke activity for handling signin/failure events
    • Follows the same pattern as existing signin activities
  3. Updated SignInInvokeActivity union

    • Added SignInFailureInvokeActivity to the discriminated union
    • Now properly handles all signin invoke types
  4. Updated exports in init files

    • Exported new classes from models and activities packages
    • Alphabetically ordered __all__ list for consistency
  5. Created fixture-based testing

    • Created test_fixtures.py with pytest parameterization for scalable fixture testing
    • Uses FIXTURE_ACTIVITY_MAP dictionary to map fixture files to activity types
    • Created fixtures/signin_failure_invoke_activity.json fixture file
    • New fixtures can be easily added by updating the map
    • All 103 API tests pass
  6. Validated with real-world data

    • Tested with the actual activity payload from the issue
    • Confirmed the error is now resolved

Verification

All Tests Pass: 103/103 tests passing
Linting: Ruff checks passed
Formatting: All files properly formatted
Type Checking: Pyright - no new errors
Security: CodeQL analysis - 0 alerts
Real-World Test: Successfully parses the actual signin/failure payload from the issue
Code Review: All feedback addressed

Impact

Before: Sign-in failures caused validation errors and prevented proper error handling.

After: Sign-in failures are gracefully handled:

  • Activities are properly deserialized
  • Error codes and messages are captured
  • No validation errors occur
  • Applications can implement custom error handling

Breaking Changes

None - fully backward compatible. Only adds new functionality.

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 and others added 2 commits November 6, 2025 02:38
Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
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
@heyitsaamir heyitsaamir marked this pull request as ready for review November 7, 2025 23:42
Copilot AI review requested due to automatic review settings November 7, 2025 23:42
Copy link
Contributor

Copilot AI left a comment

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 adds support for handling sign-in failures by introducing a new SignInFailure model and corresponding SignInFailureInvokeActivity, along with comprehensive unit tests. It also includes a minor formatting change to consolidate a multi-line decorator.

  • Adds SignInFailure model to represent authentication failure details (error code and message)
  • Introduces SignInFailureInvokeActivity for handling signin/failure invoke events with discriminated union support
  • Provides comprehensive test coverage including creation, serialization, and deserialization tests

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/mcpplugin/src/microsoft/teams/mcpplugin/server_plugin.py Reformatted the @Plugin decorator from multi-line to single-line
packages/api/src/microsoft/teams/api/models/sign_in/failure.py Added new SignInFailure model with optional code and message fields
packages/api/src/microsoft/teams/api/models/sign_in/init.py Exported the new SignInFailure model
packages/api/src/microsoft/teams/api/activities/invoke/sign_in/failure.py Added SignInFailureInvokeActivity class for handling signin/failure invokes
packages/api/src/microsoft/teams/api/activities/invoke/sign_in/init.py Added SignInFailureInvokeActivity to the discriminated union and exports
packages/api/tests/unit/test_signin_failure_activity.py Added comprehensive unit tests for the new activity class

Copy link
Collaborator

@heyitsaamir heyitsaamir left a comment

Choose a reason for hiding this comment

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

@copilot implement

Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
Copilot AI requested a review from heyitsaamir November 16, 2025 22:37
Copilot finished work on behalf of heyitsaamir November 16, 2025 22:37
Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
Co-authored-by: heyitsaamir <48929123+heyitsaamir@users.noreply.github.com>
Copilot finished work on behalf of heyitsaamir November 16, 2025 23:11
@heyitsaamir heyitsaamir merged commit 9b68b83 into main Nov 18, 2025
12 checks passed
@heyitsaamir heyitsaamir deleted the copilot/fix-signin-failure-handling branch November 18, 2025 00:52
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.

SignIn failures are not handled gracefully.

3 participants