Skip to content

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): Handle object values in FileInput component (#11948)

Bently1f4105e8f955
diff --git a/autogpt_platform/frontend/src/components/atoms/FileInput/FileInput.tsx b/autogpt_platform/frontend/src/components/atoms/FileInput/FileInput.tsx
index d43063b411..2677a7483b 100644
--- a/autogpt_platform/frontend/src/components/atoms/FileInput/FileInput.tsx
+++ b/autogpt_platform/frontend/src/components/atoms/FileInput/FileInput.tsx
@@ -104,7 +104,31 @@ export function FileInput(props: Props) {
return false;
}
- const getFileLabelFromValue = (val: string) => {
+ const getFileLabelFromValue = (val: unknown): string => {
+ // Handle object format from external API: { name, type, size, data }
+ if (val && typeof val === "object") {
+ const obj = val as Record<string, unknown>;
+ if (typeof obj.name === "string") {
+ return getFileLabel(
+ obj.name,
+ typeof obj.type === "string" ? obj.type : "",
+ );
+ }
+ if (typeof obj.type === "string") {
+ const mimeParts = obj.type.split("/");
+ if (mimeParts.length > 1) {
+ return `${mimeParts[1].toUpperCase()} file`;
+ }
+ return `${obj.type} file`;
+ }
+ return "File";
+ }
+
+ // Handle string values (data URIs or file paths)
+ if (typeof val !== "string") {
+ return "File";
+ }
+
if (val.startsWith("data:")) {
const matches = val.match(/^data:([^;]+);/);
if (matches?.[1]) {