pierrejeambrun commented on code in PR #61588:
URL: https://github.com/apache/airflow/pull/61588#discussion_r2799876909
##########
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:
https://github.com/apache/airflow/pull/61560 will take care of this and
introduce a common 'handler' with existing toaster.
Then in this PR we can centralize all the calls to the toaster handler into
this MutationCache we created. (And remove all of the manual toaster creation
call we have everywhere)
--
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]