From 8d5e266deb32090e73c6638f9785b4fbddfe3b8b Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 27 Apr 2026 15:09:05 -0700 Subject: [PATCH 1/2] fix(ui): display file upload messages --- .../knowledge/hooks/use-knowledge-upload.ts | 2 +- .../settings/hooks/use-profile-picture-upload.ts | 6 ++++-- .../user-input/hooks/use-file-attachments.ts | 13 +++++++++++-- .../components/file-upload/file-upload.tsx | 3 ++- .../w/[workflowId]/hooks/use-workflow-execution.ts | 5 +++-- .../sidebar/hooks/use-workspace-logo-upload.ts | 6 ++++-- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts b/apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts index e806947a572..54e564d05a3 100644 --- a/apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts +++ b/apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts @@ -794,7 +794,7 @@ export function useKnowledgeUpload(options: UseKnowledgeUploadOptions = {}) { } throw new DirectUploadError( - `Failed to upload ${file.name}: ${errorData?.error || 'Unknown error'}`, + `Failed to upload ${file.name}: ${errorData?.message || errorData?.error || 'Unknown error'}`, errorData ) } diff --git a/apps/sim/app/workspace/[workspaceId]/settings/hooks/use-profile-picture-upload.ts b/apps/sim/app/workspace/[workspaceId]/settings/hooks/use-profile-picture-upload.ts index ff4c582e414..f2e67be738b 100644 --- a/apps/sim/app/workspace/[workspaceId]/settings/hooks/use-profile-picture-upload.ts +++ b/apps/sim/app/workspace/[workspaceId]/settings/hooks/use-profile-picture-upload.ts @@ -78,8 +78,10 @@ export function useProfilePictureUpload({ }) if (!response.ok) { - const errorData = await response.json().catch(() => ({ error: response.statusText })) - throw new Error(errorData.error || `Failed to upload file: ${response.status}`) + const errorData = await response.json().catch(() => ({ message: response.statusText })) + throw new Error( + errorData.message || errorData.error || `Failed to upload file: ${response.status}` + ) } const data = await response.json() diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.ts b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.ts index af19b89aeb9..cfee82d8680 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.ts @@ -2,7 +2,9 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { createLogger } from '@sim/logger' +import { toError } from '@sim/utils/errors' import { generateId } from '@sim/utils/id' +import { toast } from '@/components/emcn' import { resolveFileType } from '@/lib/uploads/utils/file-utils' const logger = createLogger('useFileAttachments') @@ -147,9 +149,13 @@ export function useFileAttachments(props: UseFileAttachmentsProps) { if (!uploadResponse.ok) { const errorData = await uploadResponse.json().catch(() => ({ - error: `Upload failed: ${uploadResponse.status}`, + message: `Upload failed: ${uploadResponse.status}`, })) - throw new Error(errorData.error || `Failed to upload file: ${uploadResponse.status}`) + throw new Error( + errorData.message || + errorData.error || + `Failed to upload file: ${uploadResponse.status}` + ) } const uploadData = await uploadResponse.json() @@ -172,6 +178,9 @@ export function useFileAttachments(props: UseFileAttachmentsProps) { ) } catch (error) { logger.error(`File upload failed: ${error}`) + toast.error(`Couldn't upload "${file.name}"`, { + description: toError(error).message, + }) if (placeholder.previewUrl) URL.revokeObjectURL(placeholder.previewUrl) setAttachedFiles((prev) => prev.filter((f) => f.id !== placeholder.id)) } diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx index f3147311489..37873145533 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx @@ -328,7 +328,8 @@ export function FileUpload({ const data = await response.json() if (!response.ok) { - const errorMessage = data.error || `Failed to upload file: ${response.status}` + const errorMessage = + data.message || data.error || `Failed to upload file: ${response.status}` uploadErrors.push(`${file.name}: ${errorMessage}`) setUploadError(errorMessage) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts index 685dad3e1e1..e86588454d5 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts @@ -494,8 +494,9 @@ export function useWorkflowExecution() { logger.error('Unexpected upload response format:', uploadResult) } } else { - const errorText = await response.text() - const message = `Failed to upload ${fileData.name}: ${response.status} ${errorText}` + const errorData = await response.json().catch(() => null) + const reason = errorData?.message || errorData?.error || `${response.status}` + const message = `Failed to upload ${fileData.name}: ${reason}` logger.error(message) if (isUploadErrorCapable(workflowInput)) { try { diff --git a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-logo-upload.ts b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-logo-upload.ts index 86d99fd1b4d..d0dddb12648 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-logo-upload.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-logo-upload.ts @@ -73,8 +73,10 @@ export function useWorkspaceLogoUpload({ }) if (!response.ok) { - const errorData = await response.json().catch(() => ({ error: response.statusText })) - throw new Error(errorData.error || `Failed to upload file: ${response.status}`) + const errorData = await response.json().catch(() => ({ message: response.statusText })) + throw new Error( + errorData.message || errorData.error || `Failed to upload file: ${response.status}` + ) } const data = await response.json() From 98b918ff5708a792e05eeb8ca2c723d9c05946ca Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Mon, 27 Apr 2026 15:31:01 -0700 Subject: [PATCH 2/2] Address pr comments --- .../w/[workflowId]/hooks/use-workflow-execution.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts index e86588454d5..66054a7e4b9 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts @@ -494,8 +494,13 @@ export function useWorkflowExecution() { logger.error('Unexpected upload response format:', uploadResult) } } else { + const cloned = response.clone() const errorData = await response.json().catch(() => null) - const reason = errorData?.message || errorData?.error || `${response.status}` + const reason = + errorData?.message || + errorData?.error || + (await cloned.text().catch(() => '')) || + `${response.status}` const message = `Failed to upload ${fileData.name}: ${reason}` logger.error(message) if (isUploadErrorCapable(workflowInput)) {