Repository: Significant-Gravitas/AutoGPT
Pull request: fix: show error toast on Run failure when inputs or credentials are i…
### Fixes #8332

## Background

The issue is that when “Run” fails due to invalid inputs (e.g., deleted credentials), no error message is shown in the UI.

### Changes 🏗️

- Added toast notification (variant="destructive") for "Run" failures.
- Displays error when the execution request returns an HTTP 400 due to invalid hard-coded input values 

https://github.com/user-attachments/assets/e5686fcf-e376-40ca-876a-8cb99aec2e2e




Problem statement:
Show error if queueing graph execution fails
If clicking "Run" results in a failure, e.g. the hard-coded input values are no longer valid, this isn't visible in the UI. This can happen e.g. with credentials when they are deleted from the user but not from the graph. The execution request returns an HTTP 400 but the UI doesn't show anything.

Suggestion: show a toast (`variant="destructive"`) with the error message.

Hints from issue discussion:
@Pwuts Can i try this one??

Commit message: fix: show error toast on Run failure when inputs or credentials are invalid

Patch to review:
diff --git a/autogpt_platform/frontend/src/hooks/useAgentGraph.ts b/autogpt_platform/frontend/src/hooks/useAgentGraph.ts
index 5898b71bddb7..2e882d3ab2de 100644
--- a/autogpt_platform/frontend/src/hooks/useAgentGraph.ts
+++ b/autogpt_platform/frontend/src/hooks/useAgentGraph.ts
@@ -17,6 +17,7 @@ import { Connection, MarkerType } from "@xyflow/react";
 import Ajv from "ajv";
 import { useCallback, useEffect, useMemo, useRef, useState } from "react";
 import { useRouter, useSearchParams, usePathname } from "next/navigation";
+import { useToast } from "@/components/ui/use-toast";
 
 const ajv = new Ajv({ strict: false, allErrors: true });
 
@@ -36,6 +37,7 @@ export default function useAgentGraph(
   const [availableNodes, setAvailableNodes] = useState<Block[]>([]);
   const [updateQueue, setUpdateQueue] = useState<NodeExecutionResult[]>([]);
   const processedUpdates = useRef<NodeExecutionResult[]>([]);
+  const { toast } = useToast();
   /**
    * User `request` to save or save&run the agent, or to stop the active run.
    * `state` is used to track the request status:
@@ -413,10 +415,25 @@ export default function useAgentGraph(
     if (saveRunRequest.state === "error") {
       if (saveRunRequest.request === "save") {
         console.error("Error saving agent");
+        toast({
+          variant: "destructive",
+          title: `Error saving agent`,
+          duration: 2000,
+        });
       } else if (saveRunRequest.request === "run") {
+        toast({
+          variant: "destructive",
+          title: `Error saving&running agent`,
+          duration: 2000,
+        });
         console.error(`Error saving&running agent`);
       } else if (saveRunRequest.request === "stop") {
         console.error(`Error stopping agent`);
+        toast({
+          variant: "destructive",
+          title: `Error stopping agent`,
+          duration: 2000,
+        });
       }
       // Reset request
       setSaveRunRequest({
@@ -441,6 +458,11 @@ export default function useAgentGraph(
       } else if (saveRunRequest.request === "run") {
         if (!validateNodes()) {
           console.error("Validation failed; aborting run");
+          toast({
+            title: "Invalid credentials or inputs",
+            variant: "destructive",
+            duration: 2000,
+          });
           setSaveRunRequest({
             request: "none",
             state: "none",
diff --git a/autogpt_platform/supabase b/autogpt_platform/supabase
index 4647d50380f2..9f9b083ba5a3 160000
--- a/autogpt_platform/supabase
+++ b/autogpt_platform/supabase
@@ -1 +1 @@
-Subproject commit 4647d50380f2b7c7ba65611bd9ec474b8d6a4003
+Subproject commit 9f9b083ba5a31112ec8ceeedeb43ea6fa5958996


Code review comments:
path: autogpt_platform/supabase
text: @user1:
if we revert the change to supabase, this is good to go!