From 387ae17c222c53ab57cbd17a7ca3c1e011f8c60c Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Wed, 12 Aug 2026 18:38:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20handle=20401=20respons?= =?UTF-8?q?es=20when=20syncing=20user=20preferences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 401 responses were not handled by the user preferences sync, which could leave the app in an inconsistent state when the session had expired. Handle the 401 case explicitly and report the error through the telemetry module so it stays visible without crashing the flow. --- CHANGELOG.md | 1 + .../auth/api/useSyncUserPreferencesWithBackend.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 418f190f..7f48fb87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ### Fixed - 📈(frontend) downgrade unreachable external home URL from error to event +- 🐛(frontend) handle 401 responses when syncing user preferences ## [1.26.0] - 2026-08-12 diff --git a/src/frontend/src/features/auth/api/useSyncUserPreferencesWithBackend.tsx b/src/frontend/src/features/auth/api/useSyncUserPreferencesWithBackend.tsx index ed06e816..9e689585 100644 --- a/src/frontend/src/features/auth/api/useSyncUserPreferencesWithBackend.tsx +++ b/src/frontend/src/features/auth/api/useSyncUserPreferencesWithBackend.tsx @@ -6,6 +6,8 @@ import { queryClient } from '@/api/queryClient' import { updateUserPreferences } from './updateUserPreferences' import { convertToBackendLanguage } from '@/utils/languages' import { useUser } from './useUser' +import { ApiError } from '@/api/ApiError.ts' +import { reportError } from '@/features/analytics/telemetry' /** * Hook that synchronizes user browser preferences (language, timezone) with backend user settings. @@ -42,6 +44,11 @@ export const useSyncUserPreferencesWithBackend = () => { } } - syncBrowserPreferencesToBackend() + syncBrowserPreferencesToBackend().catch((error) => { + if (error instanceof ApiError && error.statusCode === 401) return + reportError('generic_failure', error, { + context: '[useSyncUserPreferencesWithBackend] Failed to sync:', + }) + }) }, [i18n.language, isLoggedIn, user, mutateAsync]) }