{"record":{"id":"a189b56eaa9108bc","repo":"windmill-labs/windmill","slug":"body-res-statustext","errorCode":null,"errorMessage":"body || res.statusText","messagePattern":"body \\|\\| res\\.statusText","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/SyncResourceTypes.svelte","lineNumber":24,"sourceCode":"\n\tinterface Props {\n\t\tonSynced?: () => void\n\t\t// When set, the endpoint returns an explicit not-found error if the hub does\n\t\t// not know this type (the sync itself still refreshes the whole list).\n\t\tresourceType?: string\n\t}\n\n\tlet { onSynced = undefined, resourceType = undefined }: Props = $props()\n\n\tlet hubRtSync = usePromise(\n\t\tasync () => {\n\t\t\tconst url = resourceType\n\t\t\t\t? `/api/settings/sync_cached_resource_types?name=${encodeURIComponent(resourceType)}`\n\t\t\t\t: '/api/settings/sync_cached_resource_types'\n\t\t\tconst res = await fetch(url, { method: 'POST' })\n\t\t\tif (!res.ok) {\n\t\t\t\tconst body = await res.text()\n\t\t\t\tthrow new Error(body || res.statusText)\n\t\t\t}\n\t\t\tsendUserToast('Hub resource types sync completed')\n\t\t\tonSynced?.()\n\t\t},\n\t\t{ loadInit: false }\n\t)\n</script>\n\n{#if $superadmin}\n\t<Button\n\t\tloading={hubRtSync.status === 'loading'}\n\t\tonClick={() => hubRtSync.refresh()}\n\t\tsize=\"xs\"\n\t\tvariant=\"default\"\n\t>\n\t\tSync resource types with Hub\n\t</Button>\n\t{#if hubRtSync.status === 'error'}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/SyncResourceTypes.svelte#L6-L42","documentation":"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).","triggerScenarios":"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.","commonSituations":"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).","solutions":["Check the thrown body message — it carries the backend's actual error reason","Ensure you are logged in as an instance admin (this is a settings endpoint)","Retry the sync; if 5xx persists, check backend logs for hub connectivity errors","Verify the `name` query parameter (if used) matches an existing resource type"],"exampleFix":"// before\nif (!res.ok) {\n  const body = await res.text()\n  throw new Error(body || res.statusText)\n}\n// after\nif (!res.ok) {\n  const body = await res.text()\n  sendUserToast(`Resource type sync failed (${res.status}): ${body || res.statusText}`, true)\n  return\n}","handlingStrategy":"try-catch","validationCode":"// require admin role before offering the sync button\nconst isAdmin = userStore?.is_admin || userStore?.super_admin\nif (!isAdmin) sendUserToast('Instance admin required to sync resource types', true)","typeGuard":null,"tryCatchPattern":"try {\n  await trigger()\n} catch (e) {\n  sendUserToast(`Resource type sync failed: ${e.message}`, true)\n}","preventionTips":["Run the sync as an instance admin","Verify resource-type `name` parameters exist before targeted syncs","Check backend hub connectivity if 5xx errors repeat"],"tags":["http","admin","resource-types","sync"],"backgroundTag":"http-error-response","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}