Compare commits

..

1 Commits

Author SHA1 Message Date
Bentlybro
8b1f312126 fix(frontend): Handle object values in FileInput component
Fixes #11800

The FileInput component crashed with 'TypeError: e.startsWith is not a function'
when the value was an object (from external API) instead of a string.

Changes:
- Updated getFileLabelFromValue() to handle object format: { name, type, size, data }
- Added type guards for string vs object values
- Graceful fallback for edge cases (null, undefined, empty object)

Test cases verified:
- Object with name: returns filename
- Object with type only: extracts and formats MIME type
- String data URI: parses correctly
- String file path: extracts extension
- Edge cases: returns 'File' fallback
2026-02-03 11:19:10 +00:00

View File

@@ -109,10 +109,7 @@ export function FileInput(props: Props) {
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 : "",
);
return getFileLabel(obj.name, (obj.type as string) || "");
}
if (typeof obj.type === "string") {
const mimeParts = obj.type.split("/");