Skip to content

Comments

Fix OAuth reconnect loop caused by DCR-only placeholder token#308

Merged
Dumbris merged 1 commit intomainfrom
fix/oauth-dcr-reconnect-loop-305
Feb 20, 2026
Merged

Fix OAuth reconnect loop caused by DCR-only placeholder token#308
Dumbris merged 1 commit intomainfrom
fix/oauth-dcr-reconnect-loop-305

Conversation

@Dumbris
Copy link
Contributor

@Dumbris Dumbris commented Feb 20, 2026

Summary

Fixes #305.

  • GetToken() now returns ErrNoToken when the stored record has an empty AccessToken (DCR-only placeholder)
  • This prevents scanForNewTokens() from treating DCR client credentials as a valid persisted token and triggering reconnect loops every 10 seconds

Root Cause

After logout → restart → login, DCR saves client credentials to BBolt storage before the token exchange completes. GetToken() returned a non-nil *client.Token with empty AccessToken and zero ExpiresAt for these records. scanForNewTokens() only checked tok != nil, so it continuously triggered reconnects.

The existing HasPersistedToken() helper already checked record.AccessToken != "" correctly — GetToken() now applies the same guard.

Test plan

  • Unit test reproducing DCR-only record scenario (TestGetToken_DCROnlyRecord_ReturnsError)
  • All OAuth tests pass with race detector
  • Manual test with OAuth Go test server: 38 scan cycles, 0 false reconnects
  • API E2E tests pass (no regressions)

🤖 Generated with Claude Code

After logout/restart/login, DCR saves client credentials to storage
before token exchange completes. GetToken() returned a non-nil token
for these DCR-only records (empty AccessToken, zero ExpiresAt), causing
scanForNewTokens() to trigger reconnect loops every 10 seconds.

Now GetToken() returns ErrNoToken when AccessToken is empty, consistent
with HasPersistedToken() which already checks this correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8fe86dd
Status: ✅  Deploy successful!
Preview URL: https://66a297d8.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-oauth-dcr-reconnect-loop.mcpproxy-docs.pages.dev

View logs

@github-actions
Copy link

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/oauth-dcr-reconnect-loop-305

Available Artifacts

  • archive-darwin-amd64 (23 MB)
  • archive-darwin-arm64 (21 MB)
  • archive-linux-amd64 (12 MB)
  • archive-linux-arm64 (11 MB)
  • archive-windows-amd64 (23 MB)
  • archive-windows-arm64 (21 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (26 MB)
  • installer-dmg-darwin-arm64 (23 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 22228614379 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris Dumbris merged commit fd03080 into main Feb 20, 2026
23 checks passed
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.

OAuth login loops after logout/restart: DCR placeholder token is treated as persisted token

2 participants