Adapt mutation error handling#2019
Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR centralizes mutation error handling by introducing a handleMutationError utility function and replacing direct toast calls with INTERNAL_ERROR_TOAST throughout the codebase.
Changes:
- Added
handleMutationErrorandisForbiddenMutationErrorutility functions in a newinterceptor-utils.tsfile - Replaced inline error handling (toast calls with
INTERNAL_ERROR_TOAST) with calls tohandleMutationErroracross multiple components - Updated AI model selector to conditionally show error toasts based on
isForbiddenMutationErrorcheck
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-ui/src/app/interceptors/interceptor-utils.ts | New utility file with centralized error handling functions |
| packages/react-ui/src/app/routes/settings/appearance/language-switcher.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/routes/settings/ai/index.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/templates/components/select-flow-template-dialog.tsx | Replaced inline toast error handling with handleMutationError in two mutations |
| packages/react-ui/src/app/features/folders/component/move-to-folder-dialog.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/lib/run-workflow-manually-hook.ts | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/lib/flows-hooks.ts | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/components/rename-flow-dialog.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/components/import-flow-dialog/import-flow-dialog.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/components/flow-status-toggle.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/flows/components/flow-actions-menu.tsx | Replaced inline toast error handling with handleMutationError in two mutations |
| packages/react-ui/src/app/features/flow-runs/hooks/useRunsTableColumns.tsx | Replaced inline toast error handling with handleMutationError in two mutations |
| packages/react-ui/src/app/features/connections/components/connection-table.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/test-step/test-trigger-section.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/test-step/test-action-section.tsx | Replaced inline toast error handling with handleMutationError and removed unused toast import |
| packages/react-ui/src/app/features/builder/run-list/flow-run-card.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/flow-versions/flow-versions-card.tsx | Replaced inline toast error handling with handleMutationError in two mutations |
| packages/react-ui/src/app/features/builder/flow-canvas/widgets/test-flow-widget.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/builder-hooks.ts | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/builder-header/hooks/lock-and-publish.ts | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/builder/blocks-selector/index.tsx | Replaced inline toast error handling with handleMutationError |
| packages/react-ui/src/app/features/benchmark/use-benchmark-wizard-navigation.ts | Replaced inline toast error handling with handleMutationError in two mutations |
| packages/react-ui/src/app/features/ai/lib/ai-model-selector-hook.ts | Added conditional error handling using isForbiddenMutationError |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| export function isForbiddenMutationError(_error: unknown): boolean { |
There was a problem hiding this comment.
The isForbiddenMutationError function always returns false, which makes the conditional check in ai-model-selector-hook.ts ineffective. This function should inspect the error to determine if it's a forbidden (403) error. Consider checking if the error is an AxiosError and if its status code is 403.
| export function isForbiddenMutationError(_error: unknown): boolean { | |
| import type { AxiosError } from 'axios'; | |
| export function isForbiddenMutationError(error: unknown): boolean { | |
| const maybeAxiosError = error as AxiosError | undefined; | |
| if (maybeAxiosError && (maybeAxiosError as any).isAxiosError) { | |
| return maybeAxiosError.response?.status === 403; | |
| } |
| return false; | ||
| } | ||
|
|
||
| export function handleMutationError(_error: unknown): void { |
There was a problem hiding this comment.
The handleMutationError function ignores the error parameter but doesn't log it. Consider logging the error to the console for debugging purposes, similar to how other error handlers in the codebase use console.error(error) before showing the toast.
| export function handleMutationError(_error: unknown): void { | |
| export function handleMutationError(_error: unknown): void { | |
| console.error(_error); |



Part of OPS-3673