Files
windmill/backend/windmill-api-settings
Ruben Fiszel 07d4b674f1 fix: manual resource type sync fetches from hub first, cache as fallback (#10269)
* fix: manual resource type sync fetches from hub first, cache as fallback

The superadmin "Synchronize resource types" endpoint
(POST /api/settings/sync_cached_resource_types) was cache-first: it read the
on-disk hub_rt cache and only fell back to the hub when no cache file existed.
Since that cache is refreshed by a daily cron, a newly-published hub type could
not be pulled on demand, the button replayed the stale cache and reported
"Synced 0", so the type never landed in the admins workspace.

The manual endpoint is now hub-first: it fetches the live list and upserts it
into admins, falling back to reading the on-disk cache only when the hub is
unreachable (airgapped install / network error), logging which path it took.
The startup/offline sync in main.rs (SYNC_CACHED_RT + the cache-rt cron) stays
cache-based and owns writing the cache, so this endpoint never touches it.

Adds an optional `name` query param: when a specific type is requested and is
still absent from the hub after syncing, the endpoint returns an explicit
not-found instead of a silent "Synced 0". The three not-found frontend call
sites (ResourceForm, AppConnectInner, ApiConnectForm) thread the type name
through SyncResourceTypes; the global instance-settings button stays name-less.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: run whole-list sync before the targeted not-found check, word 404 by source

Address review nits: the optional `name` check ran before the upsert loop, so a
`?name=<absent>` request skipped the whole-list refresh; move it after the loop so
the sync always happens. Also word the not-found 404 by source, the cache-fallback
path (hub unreachable) no longer claims it checked the hub.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 00:09:24 +02:00
..