fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106916
Closed
lonexreb wants to merge 1 commit into
Closed
fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106916lonexreb wants to merge 1 commit into
lonexreb wants to merge 1 commit into
Conversation
Contributor
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
probeMSTeamsmarks the MS Teams channel unhealthy (delegatedAuth.ok: false) whenever the cached delegated access token is expired (extensions/msteams/src/probe.ts). But an expired access token is not a broken connection: the delegated-token path (token.ts) refreshes it from the stored refresh token on the next API call. The result is false-positive health failures — alert spam and channel restarts — for a connector that is actually fine. The existing code even labels it "will auto-refresh on next use" while still reporting a failure. (Reported in #106566.)Why This Change Was Made
loadDelegatedTokens()returns arefreshTokenalongside the access-tokenexpiresAt, andgetDelegatedAccessToken()already auto-refreshes an expired access token using it. So the probe now treats an expired access token as healthy when a refresh token is stored (ok: !isExpired || canAutoRefresh), matching real runtime behavior. The genuine-failure signal is preserved: an expired token with no refresh token still reportsok: falsewith a clearer "re-run setup wizard" message, because that state genuinely needs operator re-auth. The probe intentionally does not attempt a network refresh to verify the refresh token server-side — that would change a cheap local health check into an API call; presence is the intended, issue-specified proxy.User Impact
MS Teams channel health checks stop firing false alarms (and stop triggering needless restarts) for connectors whose access token has simply aged out but can auto-refresh. Operators are still alerted when delegated auth is truly unrecoverable (expired with no refresh token).
Evidence
extensions/msteams/src/probe.test.ts: the prior test that assertedok: falsefor an expired-but-refreshable token is corrected to expectok: truewith no error; a new test covers expired + no refresh token →ok: falsewith the re-auth message. Full file green (5 passed) vianode scripts/run-vitest.mjs extensions/msteams/src/probe.test.ts.git diff --checkclean; 2 files, +45/−4; noCHANGELOG.mdedit.Fixes #106566