Skip to content

Add signin/failure invoke activity support#206

Merged
heyitsaamir merged 6 commits into
mainfrom
copilot/fix-signin-failure-handling
Nov 18, 2025
Merged

Add signin/failure invoke activity support#206
heyitsaamir merged 6 commits into
mainfrom
copilot/fix-signin-failure-handling

Conversation

Copilot AI commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

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 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
@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

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 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

Comment thread packages/api/src/microsoft/teams/api/models/sign_in/__init__.py Outdated

@heyitsaamir heyitsaamir 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.

@copilot implement

Comment thread packages/api/tests/unit/test_signin_failure_activity.py Outdated
Comment thread packages/api/tests/unit/test_signin_failure_activity.py Outdated
Comment thread packages/api/tests/unit/test_fixtures.py Outdated
Comment thread packages/api/tests/unit/test_signin_failure_activity.py Outdated
@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
This was referenced Nov 22, 2025
lilyydu added a commit that referenced this pull request Nov 22, 2025
## Release 2.0.0a6

### Changes

- Make images required for Thumbnail (#216)
- Revert "Add comment"
- Add comment
- Move tests to examples (#199)
- Bump glob from 11.0.3 to 11.1.0 in /tests/tab/Web (#215)
- Remove Agents class (#213)
- Add signin/failure invoke activity support (#206)
- Update config.yml (#214)
- Adds a github template when New issues are created  (#212)
- feat: add OAuth support for regional bots (#209)
- [feat] Add BotBuilder Plugin package, sample and tests (#190)

Co-authored-by: lilydu <[email protected]>
heyitsaamir added a commit to microsoft/teams.ts that referenced this pull request Dec 1, 2025
Add signin/failure invoke activity support to teams.ts

This PR applies the same changes from the Python PR
microsoft/teams.py#206 to add support for signin/failure invoke
activities.

## Changes Made:
- [x] Create SignInFailure model in
packages/api/src/models/sign-in/sign-in-failure.ts
- [x] Update packages/api/src/models/sign-in/index.ts to export
SignInFailure
- [x] Create SignInFailureInvokeActivity in
packages/api/src/activities/invoke/sign-in/failure.ts
- [x] Update packages/api/src/activities/invoke/sign-in/index.ts to
include SignInFailureInvokeActivity in the union type
- [x] Fix JSDoc formatting for consistency with TypeScript documentation
standards
- [x] Fix import order to pass linter
- [x] Add signin/failure to InvokeResponseBody in
packages/api/src/models/invoke-response.ts
- [x] Add signin/failure to InvokeAliases in
packages/apps/src/routes/invoke/index.ts
- [x] Run lint - all checks pass
- [x] Run build - all packages build successfully
- [x] Run code review - no issues found
- [x] Run security checks - no vulnerabilities found

## Summary:
Successfully resolved the issue where `signin/failure` invoke activities
would cause validation errors. The implementation follows the exact same
pattern as the Python PR microsoft/teams.py#206, adapting it to
TypeScript conventions.

### Problem
When sign-in failures occurred, the system would throw validation errors
because the `signin/failure` invoke activity type was not supported.

### Solution
Added complete support for the `signin/failure` invoke activity type:
1. **Created SignInFailure model** - Contains `code` and `message`
fields to capture failure details
2. **Created ISignInFailureInvokeActivity** - New invoke activity
interface for handling `signin/failure` events
3. **Updated SignInInvokeActivity union** - Added the failure activity
to the discriminated union type
4. **Updated InvokeResponseBody** - Added response type mapping for
signin/failure
5. **Updated InvokeAliases** - Added route alias for signin.failure

### Impact
**Before**: Sign-in failures would cause validation errors and prevent
proper error handling.

**After**: Sign-in failures are gracefully handled:
- Activities are properly typed
- Error codes and messages are captured
- No validation errors occur
- Applications can implement custom error handling
- Build and lint checks pass

### Breaking Changes
None - fully backward compatible. Only adds new functionality.

## Security Summary
No security vulnerabilities were introduced by these changes. CodeQL
analysis found no alerts.

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



<details>

<summary>Original prompt</summary>

> Can you apply a similar change from this Python PR <a
href="microsoft/teams.py#206" rel="noreferrer
noopener" title="microsoft/teams.py#206"
target="_blank">https://github.com/microsoft/teams.py/pull/206</a>?
<attachment
id="app-preview-card-ps28ff06f720cb423692ed2b1487f72acf"></attachment>
> 
> try with


</details>



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

💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: heyitsaamir <[email protected]>
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.

4 participants