Skip to content

Add API endpoint to refresh the registry cache#5268

Merged
rdimitrov merged 1 commit into
mainfrom
chip-editor
May 12, 2026
Merged

Add API endpoint to refresh the registry cache#5268
rdimitrov merged 1 commit into
mainfrom
chip-editor

Conversation

@rdimitrov
Copy link
Copy Markdown
Member

Summary

When ToolHive is configured with a custom registry API (registry_api_url), thv serve caches the registry data in memory for 1 hour. If the upstream registry changes during that window, API clients (like the UI) see stale data and have no way to ask for fresh data short of restarting the server.

This adds POST /api/v1beta/registry/{name}/refresh so the UI (or any API client) can force a refresh on demand. It does the same thing the CLI's thv registry list --refresh already does: type-asserts the provider to CachedAPIRegistryProvider and calls ForceRefresh().

Closes #5266

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

  • Unit tests added in pkg/api/v1/registry_test.go:
    • happy path: GET returns stale data, refresh succeeds, subsequent GET returns fresh data
    • non-default registry name → 404
    • unavailable upstream → 503 with registry_unavailable code
  • task lint-fix passes

Does this introduce a user-facing change?

Yes — new API endpoint POST /api/v1beta/registry/{name}/refresh (currently only default is supported). Returns {"status": "refreshed"} on success.

🤖 Generated with Claude Code

Adds POST /api/v1beta/registry/{name}/refresh so API clients (e.g. the
UI) can force a refresh of the server-side registry cache without
restarting thv serve or waiting for the 1-hour TTL.

Mirrors the CLI's `thv registry list --refresh` behavior: type-asserts to
CachedAPIRegistryProvider and calls ForceRefresh().

Closes #5266

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rdimitrov rdimitrov requested review from JAORMX and amirejaz as code owners May 12, 2026 19:30
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label May 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 47.61905% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.25%. Comparing base (110b9a7) to head (c283190).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/api/v1/registry.go 47.61% 9 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5268      +/-   ##
==========================================
+ Coverage   68.17%   68.25%   +0.08%     
==========================================
  Files         618      618              
  Lines       63122    63205      +83     
==========================================
+ Hits        43033    43143     +110     
+ Misses      16878    16841      -37     
- Partials     3211     3221      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov rdimitrov merged commit 4204858 into main May 12, 2026
46 of 47 checks passed
@rdimitrov rdimitrov deleted the chip-editor branch May 12, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registry cache in thv serve is not refreshed by CLI --refresh, and no API endpoint exists to refresh it

2 participants