Skip to content

fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106916

Closed
lonexreb wants to merge 1 commit into
openclaw:mainfrom
lonexreb:fix/106566-msteams-delegated-health
Closed

fix(msteams): keep delegated auth healthy when an expired token can auto-refresh#106916
lonexreb wants to merge 1 commit into
openclaw:mainfrom
lonexreb:fix/106566-msteams-delegated-health

Conversation

@lonexreb

Copy link
Copy Markdown
Contributor

What Problem This Solves

probeMSTeams marks 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 a refreshToken alongside the access-token expiresAt, and getDelegatedAccessToken() 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 reports ok: false with 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 asserted ok: false for an expired-but-refreshable token is corrected to expect ok: true with no error; a new test covers expired + no refresh token → ok: false with the re-auth message. Full file green (5 passed) via node scripts/run-vitest.mjs extensions/msteams/src/probe.test.ts.
  • git diff --check clean; 2 files, +45/−4; no CHANGELOG.md edit.
  • Source-reproducible: the false positive is a local health computation over stored token fields; no live MS Teams tenant is required to demonstrate it.

Fixes #106566

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@openclaw-barnacle openclaw-barnacle Bot added channel: msteams Channel integration: msteams size: XS r: too-many-prs Auto-close: author has more than twenty active PRs. labels Jul 14, 2026
@openclaw-barnacle

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: msteams Channel integration: msteams r: too-many-prs Auto-close: author has more than twenty active PRs. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] False-Positive Channel Health Failure for MS Teams on Expired Delegated Token

1 participant