gitroomhq/postiz-app · warning · Error
Failed to load errors
Error message
Failed to load errors
What it means
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.
Source
Thrown at apps/frontend/src/components/admin/admin-errors.component.tsx:166
page: number;
limit: number;
platform: string;
email: string;
unknownFirst: boolean;
}) => {
const fetch = useFetch();
const query = new URLSearchParams({
page: String(params.page),
limit: String(params.limit),
...(params.platform ? { platform: params.platform } : {}),
...(params.email ? { email: params.email } : {}),
unknownFirst: params.unknownFirst ? 'true' : 'false',
});
const key = `/admin/errors?${query.toString()}`;
return useSWR<ErrorsResponse>(key, async (url: string) => {
const res = await fetch(url);
if (!res.ok) {
throw new Error('Failed to load errors');
}
return res.json();
});
};
export const AdminErrorsComponent: FC = () => {
const user = useUser();
const modal = useModals();
const toaster = useToaster();
const [page, setPage] = useState(0);
const [limit, setLimit] = useState(20);
const [platform, setPlatform] = useState('');
const [email, setEmail] = useState('');
const [emailInput, setEmailInput] = useState('');
const [unknownFirst, setUnknownFirst] = useState(true);
const { data: platforms } = usePlatformsList();View on GitHub (pinned to 0f1647f749)
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
Example fix
// before
if (!res.ok) throw new Error('Failed to load errors');
// after
if (!res.ok) {
throw new Error(`Failed to load errors (${res.status}: ${await res.text().catch(() => '')})`);
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
const { data, error } = useErrorsList(params);
if (error) renderMessage(error.message === 'Failed to load errors' ? 'Could not load errors (check session/role)' : error.message); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to load stats
- Unauthorized
- Failed to fetch URL
- Unsupported storage provider: ${provider}
- Failed to generate posts, please try again.
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/323d22bb08283add.
Report an issue: GitHub.