fix(admin-ui): remove unwanted toast when the FIDO service is down #2885
Conversation
…2884) Signed-off-by: faisalsiddique4400 <faisalsiddique10886@gmail.com>
📝 WalkthroughWalkthroughThe useFido2HealthStatus hook cleanup
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
admin-ui/plugins/admin/components/Health/hooks/useFido2HealthStatus.ts (1)
44-52:⚠️ Potential issue | 🟠 Major | ⚡ Quick winNon-503 failures no longer trigger user-facing error notification.
By removing the error side effect entirely, this hook now suppresses toasts for all FIDO health query failures, not only
503 Service Unavailable. That breaks the stated behavior contract to keep notifications for actionable failures.Suggested fix (preserve suppression only for 503)
+import { useEffect } from 'react' +import { useTranslation } from 'react-i18next' +import { useAppDispatch, useAppSelector } from '`@/redux/hooks`' +import { updateToast } from '`@/redux/features/toastSlice`' +import { getQueryErrorMessage } from '`@/utils/getQueryErrorMessage`' @@ export const useFido2HealthStatus = (options?: { enabled?: boolean }) => { + const { t } = useTranslation() + const dispatch = useAppDispatch() const hasSession = useAppSelector((state) => state.authReducer?.hasSession) const isEnabled = (options?.enabled ?? true) && hasSession === true - return useQuery({ + const query = useQuery({ queryKey: FIDO2_HEALTH_QUERY_KEY, queryFn: ({ signal }) => fetchFido2Health(signal), enabled: isEnabled, staleTime: HEALTH_CACHE_CONFIG.STALE_TIME, gcTime: HEALTH_CACHE_CONFIG.GC_TIME, retry: false, select: transformFido2Health, }) + + useEffect(() => { + if (!query.isError) return + const status = (query.error as { response?: { status?: number } } | null)?.response?.status + if (status === 503) return + dispatch( + updateToast({ + show: true, + title: t('health.error.fetchingfido2status'), + body: getQueryErrorMessage(query.error, t), + type: 'error', + }), + ) + }, [query.isError, query.error, dispatch, t]) + + return query }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@admin-ui/plugins/admin/components/Health/hooks/useFido2HealthStatus.ts` around lines 44 - 52, The useFido2HealthStatus hook's useQuery configuration is missing error handling that previously distinguished between 503 Service Unavailable errors (which should be silently suppressed) and other actionable failures (which should show user notifications). Add an onError callback to the useQuery hook in useFido2HealthStatus that checks if the error is a 503 status code. If it is a 503, suppress the notification; otherwise, trigger an error toast notification to alert the user of the failure. This ensures the hook maintains the contract of suppressing only service unavailable errors while surfacing other meaningful failures to the user.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@admin-ui/plugins/admin/components/Health/hooks/useFido2HealthStatus.ts`:
- Around line 44-52: The useFido2HealthStatus hook's useQuery configuration is
missing error handling that previously distinguished between 503 Service
Unavailable errors (which should be silently suppressed) and other actionable
failures (which should show user notifications). Add an onError callback to the
useQuery hook in useFido2HealthStatus that checks if the error is a 503 status
code. If it is a 503, suppress the notification; otherwise, trigger an error
toast notification to alert the user of the failure. This ensures the hook
maintains the contract of suppressing only service unavailable errors while
surfacing other meaningful failures to the user.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 77830aa0-69a0-415d-ac04-9b8af8982336
📒 Files selected for processing (1)
admin-ui/plugins/admin/components/Health/hooks/useFido2HealthStatus.ts



fix(admin-ui): remove unwanted toast when the FIDO service is down (#2884)
Summary
This PR removes an unnecessary error toast that appears in the Admin UI when the FIDO service is unavailable.
The FIDO health endpoint may legitimately return
503 Service Unavailablewhen the FIDO service is down. Displaying an error toast for this expected service-health condition creates confusion for administrators and provides little actionable value.The update suppresses the toast for this specific scenario while preserving normal error handling behavior for actual user-facing failures.
Fix Summary
503 Service Unavailableresponses from the FIDO health endpointVerification
passes successfully.
503 Service Unavailable🔗 Ticket
Closes: #2884
Summary by CodeRabbit