Abhishekmishra2808 commented on code in PR #61588:
URL: https://github.com/apache/airflow/pull/61588#discussion_r2822491077


##########
airflow-core/src/airflow/ui/src/queryClient.ts:
##########
@@ -39,6 +40,31 @@ const retryFunction = (failureCount: number, error: unknown) 
=> {
   return failureCount < RETRY_COUNT;
 };
 
+// Track active 403 toast to prevent duplicates when multiple mutations fail
+let active403ToastId: string | undefined;
+
+// Error handler for 403 (Forbidden) responses on user-initiated actions
+const handle403Error = (error: unknown) => {
+  // Check for 403 (Forbidden) only to avoid interfering with 401 (Auth) logic
+  // Using nullish coalescing to safely find the status regardless of error 
shape
+  const status =
+    (error as { status?: number }).status ??
+    (error as { response?: { status?: number } }).response?.status;
+
+  if (status === 403) {
+    // Only show one 403 toast at a time to prevent toast spam
+    // when multiple mutations fail simultaneously
+    if (active403ToastId === undefined || !toaster.isActive(active403ToastId)) 
{
+      active403ToastId = toaster.create({
+        description: "You do not have permission to perform this action.",
+        title: "Insufficient Permissions",
+        type: "error",
+      });

Review Comment:
   I’ve updated the PR to use the translation system instead of hard-coded 
strings and centralized the 403 handling in MutationCache. Mutation-level 
toasters now skip 403 errors, so duplicates are no longer shown.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to