Draft
Conversation
CachedAPIRegistryProvider.refreshCache falls back to stale in-memory
cache data on any upstream error, including auth failures. This masks
a timed-out OAuth flow (or revoked credentials) as a successful list,
leaving the user no signal that they are unauthenticated.
Adds two failing reproducers that both hit the same swallow site:
TestCachedProvider_AuthErrorNotMaskedByStaleCache
server-side 401/403 rejection path (token was sent and refused)
TestCachedProvider_OAuthFlowFailureNotMaskedByStaleCache
browser-flow timeout path — the error carries neither
auth.ErrRegistryAuthRequired nor api.ErrRegistryUnauthorized,
so a naive sentinel-only fix would miss it
Refs #4950
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CachedAPIRegistryProvider.refreshCache()silently falls back to stale cached registry data when the upstream API call fails — including when the failure is an auth error. As a result,thv registry listagainst a registry behind OAuth prints previously-cached servers with no error even after the user's OAuth flow times out or their credentials are revoked. This masks the auth failure completely and is the bug reported in thv registry list serves stale cache when OAuth flow fails, masking auth failure #4950.pkg/registry/provider_cached_authbug_test.gothat exercise the two distinct error-propagation paths (server-side 401/403 and OAuth-browser-flow timeout) that both hit the same buggy fallback inrefreshCache().This PR is intentionally a draft and does not include a fix — it's a reproducer for #4950. The fix direction is under discussion in the issue because a naive sentinel-check fix is insufficient for the browser-flow path (the error carries neither
auth.ErrRegistryAuthRequirednorapi.ErrRegistryUnauthorized).Refs #4950
Type of change
Test plan
pkg/registry/provider_cached_authbug_test.go.main:task lint-fixpasses (0 issues).Special notes for reviewers
auth.TokenSource(failingTokenSource) that mirrors the exact error wrappingoauthTokenSource.Token()applies when its browser flow fails — seepkg/registry/auth/oauth_token_source.go:61-67and:110-113. This is important because a sentinel-check-only fix inrefreshCachewould catch test 1 but miss test 2, which is the user-reported scenario.tokenSource=nilso the construction-time validation probe (pkg/registry/provider_api.go:57-74) runs against the healthy server; the failure is introduced later by flipping the server's response.CachedAPIRegistryProvideris also used bypkg/api/v1/registry*.goandpkg/mcp/server/search_registry.go, so the behavior change implied by a fix will affect headless contexts too. Flagging for reviewer awareness.