6.5 KiB
Mutation Error Handlers Audit
Date: 2026-01-11
Action: 3.4.1.2 - Audit all mutation error handlers
Status: ✅ Complete
Summary
This document lists all mutation error handlers found in the codebase, identifying where mutations occur and how errors are currently handled.
Mutation Error Handler Patterns
Pattern 1: State-Managed Mutation Errors
Components that use useState to track mutation errors and display them with ErrorDisplay:
-
ProfileForm.tsx (
apps/web/src/features/user/components/ProfileForm.tsx)- Mutations: Profile update
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: 65, 172, 179-184, 224-233
-
LibraryPage.tsx (
apps/web/src/features/library/pages/LibraryPage.tsx)- Mutations: Add track to playlist, bulk delete tracks
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: 84, 145, 151, 193, 203, 220, 241-246
-
Cart.tsx (
apps/web/src/features/marketplace/components/Cart.tsx)- Mutations: Checkout
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: 26, 37, 60, 69-78
-
AccountSettings.tsx (
apps/web/src/features/settings/components/AccountSettings.tsx)- Mutations: Password change, account deletion, data export
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: 35, 61, 65, 73, 96, 120, 123
-
MarketplaceHome.tsx (
apps/web/src/pages/marketplace/MarketplaceHome.tsx)- Mutations: Product purchase
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
RolesPage.tsx (
apps/web/src/features/roles/pages/RolesPage.tsx)- Mutations: Role activation/deactivation, role deletion
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
SettingsPage.tsx (
apps/web/src/features/settings/pages/SettingsPage.tsx)- Mutations: Settings save
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
ShareDialog.tsx (
apps/web/src/features/tracks/components/ShareDialog.tsx)- Mutations: Create share link
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
CommentSection.tsx (
apps/web/src/features/tracks/components/CommentSection.tsx)- Mutations: Create comment
- Error Handling:
mutationErrorstate via React QueryonError, displayed asErrorDisplaybanner - Line: (from previous work)
-
SharePlaylistModal.tsx (
apps/web/src/features/playlists/components/SharePlaylistModal.tsx)- Mutations: Create share link
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
AddCollaboratorModal.tsx (
apps/web/src/features/playlists/components/AddCollaboratorModal.tsx)- Mutations: Add collaborator
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
-
ChatSidebar.tsx (
apps/web/src/features/chat/components/ChatSidebar.tsx)- Mutations: Leave room, delete room
- Error Handling:
mutationErrorstate via React QueryonError, displayed asErrorDisplaybanner - Line: (from previous work)
-
CreateRoomDialog.tsx (
apps/web/src/features/chat/components/CreateRoomDialog.tsx)- Mutations: Create room
- Error Handling:
mutationErrorstate, displayed asErrorDisplaybanner - Line: (from previous work)
Pattern 2: React Query useMutation with onError
Components using React Query's useMutation with onError callback:
- CommentSection.tsx - Uses
createCommentMutationwithonError - ChatSidebar.tsx - Uses
leaveRoomMutationanddeleteRoomMutationwithonError
Pattern 3: Direct API Calls with Try/Catch
Components making direct API calls with try/catch blocks:
- ProfileForm.tsx - Direct
apiClient.put()call - LibraryPage.tsx - Direct
apiClient.post()andapiClient.delete()calls - Cart.tsx - Direct
apiClient.post()call - AccountSettings.tsx - Direct
apiClient.post()andapiClient.delete()calls
Mutation Types by Category
User Management
- Profile update (ProfileForm)
- Password change (AccountSettings)
- Account deletion (AccountSettings)
- Data export (AccountSettings)
Library Management
- Add track to playlist (LibraryPage)
- Bulk delete tracks (LibraryPage)
Marketplace
- Product purchase (MarketplaceHome)
- Checkout (Cart)
Playlists
- Create share link (SharePlaylistModal)
- Add collaborator (AddCollaboratorModal)
Tracks
- Create share link (ShareDialog)
- Create comment (CommentSection)
Chat
- Create room (CreateRoomDialog)
- Leave room (ChatSidebar)
- Delete room (ChatSidebar)
Roles & Settings
- Role activation/deactivation (RolesPage)
- Role deletion (RolesPage)
- Settings save (SettingsPage)
Current Error Handling Status
✅ Already Using ErrorDisplay
All mutation error handlers identified are already using ErrorDisplay component with banner variant for error presentation.
⚠️ Missing Retry Functionality
None of the mutation error handlers currently implement retry functionality. Errors are displayed but users cannot retry failed mutations.
Recommendations
High Priority
- Add Retry Functionality (Action 3.4.1.3)
- Implement retry logic for all mutation error handlers
- Store mutation function and variables for retry
- Add retry button to ErrorDisplay (already exists, needs integration)
Medium Priority
- Retry Count Limits (Action 3.4.1.4)
- Limit retry attempts to prevent infinite loops
- Show retry count to user
- Disable retry after max attempts
Low Priority
- Optimistic Updates with Retry
- Consider optimistic updates for mutations
- Rollback on error, retry on failure
- Better UX for network failures
Files Requiring Updates
All files listed above in "Pattern 1: State-Managed Mutation Errors" will need:
- Store mutation function reference
- Store mutation variables
- Add
onRetryhandler to ErrorDisplay - Implement retry logic with attempt counting
Next Steps
- ✅ Complete: Audit all mutation error handlers
- ⏭️ Next: Implement retry for failed mutations (Action 3.4.1.3)
- ⏭️ Next: Add retry count limit (Action 3.4.1.4)