Repository navigation
fix(server): use canonical OAuth health in REST server list and diagnostics - #1622
Conversation
…ostics
Server.GetAllServers (the httpapi controller projection behind
GET /api/v1/servers/{id}/diagnostics, the REST list fallback and other
controller readers) rebuilt each server's health from connection state
only, without OAuth token status or expiry. A connected OAuth server with
a valid stored token and listed tools was therefore reported as
"Authentication required / sign_in_required / usable=false", while the
runtime, CLI and (since smart-mcp-proxy#1525) the MCP upstream_servers list reported it
Ready.
Reuse the runtime's canonical health projection, as smart-mcp-proxy#1525 did for
handleListUpstreams. The projection is adopted only when its admin state
(enabled, quarantined) matches the row's own snapshot, so one row never
mixes two admin states; otherwise, and when the runtime has no entry, the
connection-based calculation is kept as the fallback. Missing and expired
tokens still report sign-in required, and a valid token never makes a
quarantined or disabled server usable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thank you @electrolobzik — merged! 🎉 This fixes a real inconsistency: the REST list and One note from the cross-review, not blocking: the controller and runtime read two separate StateView snapshots. So for a moment during a reconnect or an endpoint change, a row could show health from a slightly newer state. It is display-only and fixes itself on the next poll. One shared projection would remove it fully, if you ever want to follow up. Thanks again for the careful work! |
Problem
Server.GetAllServerssits behindGET /api/v1/servers/{id}/diagnostics, the REST server-list fallback and the other controller readers. It rebuilt each server's health from connection state only, without the OAuth token status or expiry.As a result, a connected OAuth server with a valid stored token and listed tools was reported as "Authentication required" (
sign_in_required,usable=false). For the same server, the runtime, the CLI and the MCPupstream_serverslist (since #1525, issue #1522) all reported it as Ready.Fix
handleListUpstreams.enabled,quarantined) matches the row's own snapshot. A row therefore never mixes two admin states.Tests
New
TestServerGetAllServersOAuthHealthininternal/server/server_oauth_health_test.go. It covers these cases:It asserts that the REST/diagnostics health equals the runtime health, and checks the expected status and
usableflag.main: the "valid token" and "token without expiry" cases fail, reportingsign_in_required/usable=false. The "expired token" case fails with summary "Authentication required" instead of "Token expired".TestMCPUpstreamList*tests also still pass.Other checks:
go build ./...andgo build -tags server ./...pass.go veton./internal/server/and./internal/httpapi/passes, andgofmtis clean.internal/httpapiandinternal/healthtests pass.🤖 Generated with Claude Code