{"record":{"id":"2ed1d1177a84d91d","repo":"windmill-labs/windmill","slug":"res-statustext","errorCode":null,"errorMessage":"res.statusText","messagePattern":"res\\.statusText","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/routes/(root)/(logged)/user/(user)/instance_settings/+page.svelte","lineNumber":109,"sourceCode":"\tlet newPassword = $state('')\n\tlet enableHubSync = $state(true)\n\tlet accountSubmitting = $state(false)\n\tlet accountError = $state('')\n\tlet showOssAccountDialog = $state(false)\n\tlet ossAccountError = $state('')\n\n\t// --- Resource type sync (triggered on entering account step) ---\n\tlet rtSyncStatus: 'idle' | 'loading' | 'success' | 'error' = $state('idle')\n\tlet rtSyncMessage = $state('')\n\n\tasync function syncCachedResourceTypes() {\n\t\trtSyncStatus = 'loading'\n\t\trtSyncMessage = ''\n\t\ttry {\n\t\t\tconst res = await fetch('/api/settings/sync_cached_resource_types', { 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\trtSyncMessage = await res.text()\n\t\t\trtSyncStatus = 'success'\n\t\t} catch (e: any) {\n\t\t\trtSyncMessage = e?.message ?? 'Failed to sync resource types'\n\t\t\trtSyncStatus = 'error'\n\t\t}\n\t}\n\n\t$effect(() => {\n\t\tif (\n\t\t\trtSyncStatus === 'idle' &&\n\t\t\t((mode === 'wizard' && !isSettingsStep(wizardStep)) || (mode === 'full' && fullStep === 1))\n\t\t) {\n\t\t\tsyncCachedResourceTypes()\n\t\t}\n\t})\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/routes/(root)/(logged)/user/(user)/instance_settings/+page.svelte#L91-L127","documentation":"syncCachedResourceTypes POSTs to /api/settings/sync_cached_resource_types and throws Error(body || res.statusText) on a non-OK response. When the backend returns no body, the thrown message falls back to res.statusText (e.g. 'Forbidden', 'Internal Server Error'), surfacing the HTTP failure in the settings UI.","triggerScenarios":"Clicking the resource-type sync action in instance settings while the POST returns 4xx/5xx — e.g. non-superadmin session (403), endpoint missing on older backend (404), or backend failure computing the sync (500) with an empty body.","commonSituations":"Logged in as a workspace admin rather than instance superadmin; running a frontend newer than the backend so /api/settings/sync_cached_resource_types does not exist; backend crash during sync leaving an empty error body.","solutions":["Log in as the instance superadmin (admin@windmill.dev) — the endpoint is superadmin-only","Check the backend logs for the sync handler's failure and fix the underlying cause","Ensure backend and frontend versions match so the endpoint exists","Inspect the network tab: the response body/status tells whether it's 403 auth or 500 server error"],"exampleFix":"// before\nthrow new Error(body || res.statusText)\n// after\nthrow new Error(`sync_cached_resource_types failed (${res.status}): ${body || res.statusText}`)","handlingStrategy":"try-catch","validationCode":"// confirm superadmin session before syncing\nconst me = await fetch('/api/users/me', { credentials: 'include' })\nif (!me.ok || !(await me.json())?.is_admin) {\n  sendUserToast('Instance superadmin required to sync resource types', true)\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await syncCachedResourceTypes()\n} catch (e) {\n  if (e.message === 'Forbidden') sendUserToast('Log in as instance superadmin', true)\n  else if (e.message === 'Not Found') sendUserToast('Backend too old for this endpoint — upgrade', true)\n  else sendUserToast(e.message || 'Failed to sync resource types', true)\n}","preventionTips":["Gate the sync button on superadmin status so it's not clickable for plain admins","Keep backend and frontend versions in lockstep","Include HTTP status in thrown messages for faster diagnosis","Check backend logs whenever the sync returns an empty body"],"tags":["http","permissions","admin","frontend"],"backgroundTag":"http-request-failed","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"}