AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): Improve error handling for invalid agent files (#11165)
seer-by-sentry[bot]0f19d014832f
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryUploadAgentDialog/useLibraryUploadAgentDialog.ts b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryUploadAgentDialog/useLibraryUploadAgentDialog.tsindex 8de5353782..4bbd0eb2e6 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryUploadAgentDialog/useLibraryUploadAgentDialog.ts+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/LibraryUploadAgentDialog/useLibraryUploadAgentDialog.ts@@ -82,7 +82,7 @@ export const useLibraryUploadAgentDialog = () => {)) {throw new Error(- "Invalid agent object in file: " + JSON.stringify(obj, null, 2),+ "Invalid agent file. Please upload a valid agent.json file that has been previously exported from the AutoGPT platform. The file must contain the required fields: name, description, nodes, and links.",);}const agent = obj as Graph;@@ -96,6 +96,17 @@ export const useLibraryUploadAgentDialog = () => {}} catch (error) {console.error("Error loading agent file:", error);++ toast({+ title: "Invalid Agent File",+ description:+ "Please upload a valid agent.json file that has been previously exported from the AutoGPT platform. The file must contain the required fields: name, description, nodes, and links.",+ duration: 5000,+ variant: "destructive",+ });++ form.resetField("agentFile");+ setAgentObject(null);}};reader.readAsText(file);