Repository navigation
Commit 527097b
fix(health): stop judging header-auth servers by a stale OAuth token record (#1262)
* fix(health): stop judging header-auth servers by a stale OAuth token record
A server that once logged in with OAuth (autodiscovery, no `oauth` block)
and was then switched to a static `Authorization` header keeps its old
record in the oauth_tokens bucket: nothing removes it because the config
never carried an OAuth block whose removal could have cleared it. The
server-list projection built an `oauth` object from that dead record and,
once its expiry passed, health reported the connected, tool-serving server
as unhealthy / "Token expired" / login forever. After logout the in-memory
refresh schedule outlived the token and the same server flipped to
"Refresh token expired".
- config: add ServerConfig.HasStaticAuthorizationHeader (case-insensitive
name, non-blank value). OAuth populates that very header and the
headers-auth strategy runs first, so the two are mutually exclusive.
- runtime: a server with no `oauth` block and a static Authorization
header no longer consults the stored token for its projection. The
record is left alone (logout still removes it); it is simply not
evidence for such a server.
- health: refresh state only applies when OAuthRequired — it is a
property of the token being refreshed.
- runtime: TriggerOAuthLogout drops the refresh schedule alongside the
token, as server removal already did.
Closes #1172
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(health): let the live auth strategy override the static-header gate
Review round 1 (opencode/astra): a rejected static Authorization header
can fall through to the OAuth strategy, which then authenticates the
connection with the stored token — and the header-based gate would have
hidden that token's state. Record the strategy that won each HTTP/SSE
connect attempt (core.Client.AuthStrategy, via a shared runAuthStrategies
loop replacing the two identical ones), expose it as
managed.Client.ConnectedWithOAuth, and let the runtime consult the stored
token whenever the live connection was made with OAuth.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(health): withhold stale refresh state through one runtime seam, not the calculator
Review round 2 (opencode/astra): guarding the calculator's refresh-state
branch on OAuthRequired hid genuine refresh failures on the two surfaces
(Server.GetAllServers for the tray, the MCP upstream_servers list) that
only learn OAuthRequired from an explicit `oauth` block — an autodiscovery
OAuth server with a failed refresh would have read healthy there.
Revert the calculator change and move the decision to where the evidence
is: Runtime.StoredOAuthTokenInPlay(name, cfg) answers "is the oauth_tokens
record (and the RefreshManager schedule built from it) evidence about
this server", and Runtime.HealthRefreshState wraps GetRefreshState with
it. All three CalculateHealth call sites now read refresh state through
that seam, so a header-authenticated server's stale schedule is withheld
everywhere and an autodiscovery server's genuine failure is kept.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent fe3f4e3 commit 527097b
12 files changed
Lines changed: 555 additions & 78 deletions
File tree
- internal
- config
- runtime
- server
- upstream
- core
- managed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2151 | 2151 | | |
2152 | 2152 | | |
2153 | 2153 | | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
2154 | 2177 | | |
2155 | 2178 | | |
2156 | 2179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2364 | 2364 | | |
2365 | 2365 | | |
2366 | 2366 | | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
2367 | 2372 | | |
2368 | 2373 | | |
2369 | 2374 | | |
2370 | 2375 | | |
2371 | | - | |
| 2376 | + | |
2372 | 2377 | | |
2373 | 2378 | | |
2374 | 2379 | | |
| |||
2655 | 2660 | | |
2656 | 2661 | | |
2657 | 2662 | | |
2658 | | - | |
2659 | | - | |
2660 | | - | |
2661 | | - | |
2662 | | - | |
2663 | | - | |
2664 | | - | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
2665 | 2668 | | |
2666 | 2669 | | |
2667 | 2670 | | |
| |||
2914 | 2917 | | |
2915 | 2918 | | |
2916 | 2919 | | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
2917 | 2969 | | |
2918 | 2970 | | |
2919 | 2971 | | |
| |||
2938 | 2990 | | |
2939 | 2991 | | |
2940 | 2992 | | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
2941 | 3001 | | |
2942 | 3002 | | |
2943 | 3003 | | |
| |||
0 commit comments