{"record":{"id":"323d22bb08283add","repo":"gitroomhq/postiz-app","slug":"failed-to-load-errors","errorCode":null,"errorMessage":"Failed to load errors","messagePattern":"Failed to load errors","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/frontend/src/components/admin/admin-errors.component.tsx","lineNumber":166,"sourceCode":"  page: number;\n  limit: number;\n  platform: string;\n  email: string;\n  unknownFirst: boolean;\n}) => {\n  const fetch = useFetch();\n  const query = new URLSearchParams({\n    page: String(params.page),\n    limit: String(params.limit),\n    ...(params.platform ? { platform: params.platform } : {}),\n    ...(params.email ? { email: params.email } : {}),\n    unknownFirst: params.unknownFirst ? 'true' : 'false',\n  });\n  const key = `/admin/errors?${query.toString()}`;\n  return useSWR<ErrorsResponse>(key, async (url: string) => {\n    const res = await fetch(url);\n    if (!res.ok) {\n      throw new Error('Failed to load errors');\n    }\n    return res.json();\n  });\n};\n\nexport const AdminErrorsComponent: FC = () => {\n  const user = useUser();\n  const modal = useModals();\n  const toaster = useToaster();\n\n  const [page, setPage] = useState(0);\n  const [limit, setLimit] = useState(20);\n  const [platform, setPlatform] = useState('');\n  const [email, setEmail] = useState('');\n  const [emailInput, setEmailInput] = useState('');\n  const [unknownFirst, setUnknownFirst] = useState(true);\n\n  const { data: platforms } = usePlatformsList();","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/apps/frontend/src/components/admin/admin-errors.component.tsx#L148-L184","documentation":"The admin errors panel's SWR hook fetches /admin/errors and throws 'Failed to load errors' on any non-2xx response. The generic message hides the real cause, which is almost always authorization (admin-only route) or an expired session.","triggerScenarios":"Opening the admin errors page without admin role (403), with an expired JWT/session (401), or when the backend route is down/misrouted (404/500). Any non-ok status triggers it.","commonSituations":"Session expired while sitting on the admin page; non-admin user navigating directly to /admin; backend not running locally; a new deployment changing the /admin/errors route path.","solutions":["Open the request in devtools and read the actual status code (401/403 vs 500)","If 401: re-login; if 403: verify the user's role is ADMIN in the database","If 404/500: check the backend route exists and backend logs for exceptions","Improve the hook to surface res.status/text() in the thrown error for faster diagnosis"],"exampleFix":"// before\nif (!res.ok) throw new Error('Failed to load errors');\n\n// after\nif (!res.ok) {\n  throw new Error(`Failed to load errors (${res.status}: ${await res.text().catch(() => '')})`);\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"const { data, error } = useErrorsList(params);\nif (error) renderMessage(error.message === 'Failed to load errors' ? 'Could not load errors (check session/role)' : error.message);","preventionTips":["Check res.status and include it in thrown errors","Handle 401 with a re-login flow","Gate the admin route by role on the client too"],"tags":["admin","swr","frontend","fetch"],"backgroundTag":"http-request-non-ok","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}