Repository navigation
fix(registry): propagate registry errors from ListAvailableSkills - #6753
Conversation
ListAvailableSkills returned (nil, nil) when the registry fetch failed and no cache was warm, and served stale skills on a 401/403. The v0.1 registry route turns that into HTTP 200 with an empty skills list, so an unreachable registry or a revoked token reads as "this registry has no skills", and a revoked token hides the need to re-auth. ListAvailablePlugins, 30 lines below, already documents the intended contract and implements it: auth failures always propagate, transient failures degrade to stale cache when one exists, and with no stale cache the error is returned so the route surfaces a real failure. This change makes skills match, and states the same contract in its doc comment. Signed-off-by: fei <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6753 +/- ##
==========================================
+ Coverage 79.57% 79.60% +0.03%
==========================================
Files 814 814
Lines 82515 82528 +13
==========================================
+ Hits 65660 65696 +36
+ Misses 16850 16827 -23
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
The reported cold-cache failure and upstream 401/403 behavior are confirmed, and the regression tests pass with this fix. Before merging, please preserve the behavior for a valid servers-only registry: when the optional skills endpoint is absent (404), the unconditional error return in provider_cached.go:470 turns the previous empty list into an HTTP 500 response. Please distinguish this unsupported-endpoint case from actual outage/auth failures and add regression coverage. A targeted diagnostic passes against the base implementation and fails against this PR.
Separately, token-acquisition failures still return stale skills because they carry auth.ErrRegistryAuthRequired rather than RegistryHTTPError. This predates the PR, so it is non-blocking feedback: please consider the existing server-cache sentinel check and a regression test here or in a follow-up. The handler's 503 mapping can remain separate as proposed.
The failing GitHub Actions Static Analysis check concerns action-version comments in workflow files unchanged by this PR.
|
Thanks @Sanskarzz — addressed in
Both behaviors are pinned by new tests in |
|
@feiiiiii5 Thanks for addressing the earlier cases. One remaining issue: a 404 on a later pagination page still becomes an empty successful response, even after page one returned skills. Please limit the unsupported-endpoint fallback to the initial request and add regression coverage for cold and expired warm caches. Once that’s addressed, we can finish the review. |
ListSkills auto-paginates, so a 404 on a later page reached the same handler that reads 404 as "this registry has no skills endpoint" and returned an empty list with no error, dropping the pages that were already fetched. The client now marks only a first-page 404 as a missing endpoint and returns the plain HTTP error for any later one, and the provider matches on that. Signed-off-by: Chen Yufeiyang <[email protected]>
|
Done in The distinction is now made where the requests are made.
Regression coverage for the two cache states you asked for:
|
|
The single red check here is failing on main too, so it is not from this change.
The other 41 checks on this head are green, including |
|
Base job: https://github.com/stacklok/toolhive/actions/runs/37968068354/job/113950374126 Same spec, same 30 s timeout, and 23 other cases in that suite pass on both runs. The diff here only touches |
|
Here it is the identical spec, |
|
Both points from your 10-07 review are addressed on the current head (
Transient failures still fall back to stale cache when present, and return the error when there is none, so the route can no longer answer
Could you take a fresh look when you have a moment? I am happy to adjust the 404 distinction if you would rather treat a missing endpoint differently. |
Sanskarzz
left a comment
There was a problem hiding this comment.
LGTM. The first-page versus later-page 404 handling and token-acquisition fixes address our feedback, with regression coverage for both cache states. Local registry tests and CI pass. Thanks for following through!
Summary
ListAvailableSkillsreturned(nil, nil)when the registry fetch failed with no warm cache, and served stale skills on a 401/403. The v0.1 registry route turns that into HTTP 200 with an emptyskillsarray, so an unreachable registry or a revoked token reads as "this registry has no skills".ListAvailablePlugins, which already implements the intended contract 30 lines below and documents it in its doc comment: auth failures always propagate, transient failures degrade to stale cache when one exists, and with no stale cache the error is returned.Fixes #6752
Type of change
Test plan
task test)task test-e2e)task lint-fix)The two
tasktargets could not run in my environment, for a reason unrelated to this change, so I am not claiming them:task testrunstask genfirst, which shells out tomockgen.mockgen@latestis built with go1.24 and refuses packages that declare go1.27, so it exits 1 forpkg/vmcp/*andpkg/workloads/*. Those packages are untouched here.task lintfails before linting:golangci-lint's newest release (v2.14.0, the version pinned in.github/workflows/lint.yml) is built with go1.26 and reports "the Go language version used to build golangci-lint is lower than the targeted Go version (1.27.0)".What I did run
What I did run:
Red/green, reverting only
provider_cached.gotoorigin/mainand keeping the new test file:With the change, all three skills tests pass.
TestCachedProvider_SkillsTransient500WithWarmCacheis the control and passes on both sides, pinning the part of the behaviour that should not change.API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.No operator API surface is touched.
Does this introduce a user-facing change?
Yes, and it is the fix: the skills registry route can now return a non-200 instead of an empty list when the upstream registry fails or the token is revoked. Clients that currently treat an empty
skillsarray as "registry has no skills" will start seeing an error in those cases, which is the intended signal.Special notes for reviewers
provider_cached_plugins_errors_test.godeliberately, including thenewSkillsStatusServerhelper shape and the cache-expiry idiom. I did not add aForceRefreshcase for skills becauseprovider_cached.go:169-171invalidatesskillsCacheSeton the same path the plugins test already covers, and a second copy would be redundant.registry_v01_skills.godeclares@Failure 503 ... "Registry authentication required or upstream registry unavailable"but never callswriteRegistryUnavailableError, so that documented 503 is unreachable from this handler today. Making the error propagate is the prerequisite; wiring the handler to map it is a separate change and I would rather not bundle it. Happy to follow up if you want the 503 in this PR instead.provider_cached_plugins_test.go:109-112still has a comment saying plugins returns nil "mirroring the skills behavior". That was accurate when written and is now stale in both directions: plugins returns the error, and after this PR skills does too. I left it alone since it is in a file this PR does not otherwise touch.Signed-off-bytrailer.Implementation plan
Approved implementation plan
Not AI-planned in the sense this section expects: this came out of reading
provider_cached.goand noticing thatListAvailableSkillsandListAvailablePluginsdisagree about what to do with an error. The plan was to make the smaller one match the larger one rather than invent a third behaviour, which is why the doc comment on the plugins path is quoted in the issue and the tests mirror that file.