windmill-labs/windmill · error · Error

body || res.statusText

Error message

body || res.statusText

What it means

The SyncResourceTypes component POSTs to /api/settings/sync_cached_resource_types to refresh hub-cached resource types. On a non-OK response it reads the body text and throws Error(body || res.statusText), surfacing the backend's error message (or the status text when the body is empty).

Source

Thrown at frontend/src/lib/components/SyncResourceTypes.svelte:24

	interface Props {
		onSynced?: () => void
		// When set, the endpoint returns an explicit not-found error if the hub does
		// not know this type (the sync itself still refreshes the whole list).
		resourceType?: string
	}

	let { onSynced = undefined, resourceType = undefined }: Props = $props()

	let hubRtSync = usePromise(
		async () => {
			const url = resourceType
				? `/api/settings/sync_cached_resource_types?name=${encodeURIComponent(resourceType)}`
				: '/api/settings/sync_cached_resource_types'
			const res = await fetch(url, { method: 'POST' })
			if (!res.ok) {
				const body = await res.text()
				throw new Error(body || res.statusText)
			}
			sendUserToast('Hub resource types sync completed')
			onSynced?.()
		},
		{ loadInit: false }
	)
</script>

{#if $superadmin}
	<Button
		loading={hubRtSync.status === 'loading'}
		onClick={() => hubRtSync.refresh()}
		size="xs"
		variant="default"
	>
		Sync resource types with Hub
	</Button>
	{#if hubRtSync.status === 'error'}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Check the thrown body message — it carries the backend's actual error reason
  2. Ensure you are logged in as an instance admin (this is a settings endpoint)
  3. Retry the sync; if 5xx persists, check backend logs for hub connectivity errors
  4. Verify the `name` query parameter (if used) matches an existing resource type

Example fix

// before
if (!res.ok) {
  const body = await res.text()
  throw new Error(body || res.statusText)
}
// after
if (!res.ok) {
  const body = await res.text()
  sendUserToast(`Resource type sync failed (${res.status}): ${body || res.statusText}`, true)
  return
}
Defensive patterns

Strategy: try-catch

Validate before calling

// require admin role before offering the sync button
const isAdmin = userStore?.is_admin || userStore?.super_admin
if (!isAdmin) sendUserToast('Instance admin required to sync resource types', true)

Try / catch

try {
  await trigger()
} catch (e) {
  sendUserToast(`Resource type sync failed: ${e.message}`, true)
}

Prevention

When it happens

Trigger: POST /api/settings/sync_cached_resource_types returns non-2xx — hub sync endpoint failing server-side, missing admin permissions, or the optional `name` query parameter referencing an unknown resource type.

Common situations: Running the sync as a non-admin user (403); the hub cache service being unreachable from the backend (5xx); syncing a specific resource type name that no longer exists (404).

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/a189b56eaa9108bc. Report an issue: GitHub.