mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend): Improve error handling for invalid agent files (#11165)
### Changes 🏗️ <img width="672" height="761" alt="Screenshot 2025-10-14 at 16 12 50" src="https://github.com/user-attachments/assets/9e664ade-10fe-4c09-af10-b26d10dca360" /> Fixes [BUILDER-3YG](https://sentry.io/organizations/significant-gravitas/issues/6942679655/). The issue was that: User uploaded an incompatible external agent persona file lacking required flow graph keys (`nodes`, `links`). - Improves error handling when an invalid agent file is uploaded. - Provides a more user-friendly error message indicating the file must be a valid agent.json file exported from the AutoGPT platform. - Clears the invalid file from the form and resets the agent object to null. This fix was generated by Seer in Sentry, triggered by Toran Bruce Richards. 👁️ Run ID: 1943626 Not quite right? [Click here to continue debugging with Seer.](https://sentry.io/organizations/significant-gravitas/issues/6942679655/?seerDrawer=true) ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Test that uploading an invalid agent file (e.g., missing `nodes` or `links`) triggers the improved error handling and displays the user-friendly error message. - [x] Verify that the invalid file is cleared from the form after the error, and the agent object is reset to null. --------- Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com> Co-authored-by: Swifty <craigswift13@gmail.com> Co-authored-by: Lluis Agusti <hi@llu.lu>
This commit is contained in:
committed by
GitHub
parent
112c39f6a6
commit
0f19d01483
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user