fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106923
fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106923lonexreb wants to merge 1 commit into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 8:20 PM ET / July 14, 2026, 00:20 UTC. Summary PR surface: Source +6, Tests +35. Total +41 across 2 files. Reproducibility: yes. at source level: current main deterministically marks every non-future delegated access token unhealthy, while the runtime retains a refresh token for next-use renewal. No live current-main tenant reproduction was supplied. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the plugin-owned predicate and explicit no-refresh-token recovery message, then merge after redacted real-setup evidence demonstrates the intended health result and successful next-use refresh behavior. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main deterministically marks every non-future delegated access token unhealthy, while the runtime retains a refresh token for next-use renewal. No live current-main tenant reproduction was supplied. Is this the best way to solve the issue? Yes—the owning Teams probe is the narrowest maintainable boundary, and checking refresh-token availability matches the existing local auto-refresh contract while preserving the explicit unrecoverable case. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b4c311e51bc9. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +6, Tests +35. Total +41 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
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, and the delegated path 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). The genuine-failure signal is preserved: expired with no refresh token still reportsok: falsewith a clearer "re-run setup wizard" message. The probe intentionally does not attempt a network refresh to verify the token server-side — that would turn a cheap local health check into an API call; presence is the 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.
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