Repository navigation
fix(oauth): treat zero ExpiresAt as never-expires in HasPersistedToken - #2
Conversation
Authorization servers that omit `expires_in` from the /token response (e.g. Atlassian's MCP endpoint at https://mcp.atlassian.com/v1/mcp) land in BBolt with ExpiresAt = time.Time{}. HasValidToken and mcp-go's own Token.IsExpired() already treat that as "never expires", but HasPersistedToken was computing `time.Now().After(time.Time{})` which is always true — so the persisted token was reported as expired on every reconnect, skipBrowserFlow stayed false, and the upstream looped forever asking for re-auth even though a valid access token sat in storage. Fix HasPersistedToken to short-circuit on IsZero(), matching HasValidToken. Also clean up PersistentTokenStore.GetToken so it no longer logs a spurious "token has expired" warning for those records. Add three unit tests covering the zero / future / past ExpiresAt cases against HasPersistedToken so the IsZero branch can't regress.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughOAuth token expiration handling is updated to recognize tokens with unset ChangesOAuth Zero-Expiry Token Semantics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Fork mirror of the upstream PR (smart-mcp-proxy#453) so
halo-maingets the fix immediately rather than waiting for upstream review.Replaces #1, which had the wrong base (branch was forked off
upstream/main, so the diff included all ofhalo-main..upstream/main). This branch is cherry-picked ontohalo-main, so the diff is only the 3 oauth files.What this fixes
OAuth re-auth loop observed against Atlassian's MCP endpoint (
https://mcp.atlassian.com/v1/mcp) — authorization succeeds in the browser, the token is persisted, butHasPersistedTokenwas treatingtime.Time{}ExpiresAtas expired (time.Now().After(time.Time{})is always true), so every reconnect looped asking for re-auth even though a valid bearer token was on disk.Details, root cause, and test coverage: see the upstream PR.
Test plan
go test ./internal/oauth/— green (14.9 s)go test ./internal/upstream/...— green🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests