{"record":{"id":"6507e42570ca7150","repo":"windmill-labs/windmill","slug":"http-response-status","errorCode":null,"errorMessage":"HTTP ${response.status}","messagePattern":"HTTP \\$\\{response\\.status\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/instanceSettings/DbHealth.svelte","lineNumber":34,"sourceCode":"\tlet slowSort: SlowQuerySort = $state('total')\n\tlet slowSortLoading = $state(false)\n\tlet expandedQueries: Record<number, boolean> = $state({})\n\n\tasync function resetSlowStats() {\n\t\tif (\n\t\t\t!confirm(\n\t\t\t\t'Reset pg_stat_statements? This clears cumulative stats for ALL queries on this postgres instance.'\n\t\t\t)\n\t\t)\n\t\t\treturn\n\t\ttry {\n\t\t\tconst response = await fetch(`/api/db_health/slow_queries/reset`, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tcredentials: 'include'\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text()\n\t\t\t\tthrow new Error(text || `HTTP ${response.status}`)\n\t\t\t}\n\t\t\t// refetch with current sort\n\t\t\tconst refetch = await fetch(`/api/db_health/slow_queries?sort=${slowSort}`, {\n\t\t\t\tcredentials: 'include'\n\t\t\t})\n\t\t\tif (refetch.ok && data) {\n\t\t\t\tdata.slow_queries = await refetch.json()\n\t\t\t\texpandedQueries = {}\n\t\t\t}\n\t\t\tsendUserToast('pg_stat_statements reset successfully', false)\n\t\t} catch (e: any) {\n\t\t\tsendUserToast('Failed to reset stats: ' + e.message, true)\n\t\t}\n\t}\n\n\tasync function setSlowSort(sort: SlowQuerySort) {\n\t\tif (sort === slowSort || slowSortLoading) return\n\t\tslowSort = sort","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/instanceSettings/DbHealth.svelte#L16-L52","documentation":"resetSlowStats in DbHealth.svelte POSTs to /api/db_health/slow_queries/reset and throws 'HTTP <status>' when the server responds with a non-2xx status AND an empty body. The response body text is preferred as the error message; the HTTP status fallback only appears when the backend returns no body.","triggerScenarios":"Calling resetSlowStats() when the reset endpoint returns an error status with an empty response body — e.g. 401/403 (not admin or expired session), 404/405 (endpoint unavailable in this build/version), or 500 with empty body.","commonSituations":"Non-admin user opening the instance-settings DB health page (endpoint requires admin); session token expired; running an older backend without the db_health endpoints (404).","solutions":["Check the browser network tab for the actual HTTP status of /api/db_health/slow_queries/reset","Log in again as an admin user if the status is 401/403","Verify the backend version supports the db_health endpoints (404 means the route does not exist)","Check backend logs for a 5xx trace if the server errored with an empty body"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const session = await getSession()\nif (!session || !isAdmin(session)) { showLoginPrompt(); return }","typeGuard":"function isOk(r: Response): r is Response & { ok: true } { return r.ok }","tryCatchPattern":"try {\n  await resetSlowStats()\n} catch (e) {\n  sendUserToast('Could not reset slow query stats: ' + e.message, true)\n  if (e.message === 'HTTP 401' || e.message === 'HTTP 403') reAuth()\n}","preventionTips":["Only expose/use this action as an instance admin","Handle session expiry by re-authenticating on 401","Confirm the backend version includes /api/db_health/slow_queries/reset","Check backend logs when the error message is a bare 'HTTP 5xx' (empty body)"],"tags":["http","api","permissions"],"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"}