Skip to content

Adapt mutation error handling#2019

Merged
alexandrudanpop merged 1 commit intomainfrom
chore/forbidden
Feb 26, 2026
Merged

Adapt mutation error handling#2019
alexandrudanpop merged 1 commit intomainfrom
chore/forbidden

Conversation

@alexandrudanpop
Copy link
Copy Markdown
Contributor

Part of OPS-3673

Copilot AI review requested due to automatic review settings February 26, 2026 14:56
@linear
Copy link
Copy Markdown

linear Bot commented Feb 26, 2026

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 handleMutationError and isForbiddenMutationError utility functions in a new interceptor-utils.ts file
  • Replaced inline error handling (toast calls with INTERNAL_ERROR_TOAST) with calls to handleMutationError across multiple components
  • Updated AI model selector to conditionally show error toasts based on isForbiddenMutationError check

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.

Comment on lines +2 to +3

export function isForbiddenMutationError(_error: unknown): boolean {
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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;
}

Copilot uses AI. Check for mistakes.
return false;
}

export function handleMutationError(_error: unknown): void {
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
export function handleMutationError(_error: unknown): void {
export function handleMutationError(_error: unknown): void {
console.error(_error);

Copilot uses AI. Check for mistakes.
@alexandrudanpop alexandrudanpop merged commit 3d8ba1c into main Feb 26, 2026
24 of 25 checks passed
@alexandrudanpop alexandrudanpop deleted the chore/forbidden branch February 26, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants