Skip to content

fix(ui): display file upload error messages#4315

Merged
TheodoreSpeaks merged 2 commits intostagingfrom
fix/invalid-file-types
Apr 27, 2026
Merged

fix(ui): display file upload error messages#4315
TheodoreSpeaks merged 2 commits intostagingfrom
fix/invalid-file-types

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Our file upload wasn't parsing the correct field on error. In addition, uploading to mothership chat with bad types causes it to just disappear after upload. Fixed this by adding a toast and using the right path.
Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Validated that incorrect file types will cause a toast in mothership chat.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 27, 2026 10:31pm

Request Review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 27, 2026

PR Summary

Low Risk
Low risk: changes are limited to client-side upload error parsing/display and a new toast notification, without altering upload behavior or server APIs.

Overview
Improves file upload failure UX across the app. Upload callers now prefer server message (fallback to error) when constructing upload error strings, so users see the real validation/permission reason.

For mothership/copilot chat attachments, failed uploads now trigger a toast.error (and still clean up the placeholder/preview), preventing “silent” disappearance after an upload attempt.

Reviewed by Cursor Bugbot for commit 98b918f. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8d5e266. Configure here.

@TheodoreSpeaks TheodoreSpeaks marked this pull request as ready for review April 27, 2026 22:23
@TheodoreSpeaks TheodoreSpeaks changed the title fix(ui): display file upload messages fix(ui): display file upload error messages Apr 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR fixes error message extraction across six file-upload hooks by preferring the message field over error in API error responses, and adds a toast.error() notification in use-file-attachments.ts so copilot chat users see feedback when an upload fails instead of the file silently disappearing.

Confidence Score: 4/5

Safe to merge; the one P2 concern is a minor regression in error-log detail for non-JSON server responses in the workflow execution path.

All changes are narrow, focused bug fixes with consistent patterns. The only issue is that use-workflow-execution.ts trades response.text() for response.json().catch(() => null), which drops the error body when the server returns non-JSON — reducing log fidelity rather than breaking functionality.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts — the switch from text() to json() may lose error detail for non-JSON responses.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts Adds errorData?.message fallback before errorData?.error for more accurate error propagation — clean, minimal change.
apps/sim/app/workspace/[workspaceId]/settings/hooks/use-profile-picture-upload.ts Updates catch fallback to { message } and adds message priority in error extraction — consistent with fix pattern.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.ts Adds toast.error() on upload failure so the user gets visible feedback; fixes error field priority to prefer message over error.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx Adds data.message priority before data.error when extracting error message after failed upload — safe one-liner fix.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts Switches from response.text() to response.json() for error reading; risks losing error body detail when server returns non-JSON responses.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-logo-upload.ts Same pattern fix as profile-picture-upload — fallback and priority updated to message field consistently.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[File selected / dropped] --> B[POST /api/upload]
    B --> C{response.ok?}
    C -- Yes --> D[Extract URL from response]
    D --> E[Attach file to message / block]
    C -- No --> F[Parse response body]
    F --> G{JSON parse ok?}
    G -- Yes --> H["errorData.message || errorData.error"]
    G -- No --> I[Fallback: status code / statusText]
    H --> J[throw Error with message]
    I --> J
    J --> K[catch block]
    K --> L[logger.error]
    K --> M["toast.error (use-file-attachments only)"]
    K --> N[Remove placeholder / set upload error]
Loading

Reviews (1): Last reviewed commit: "fix(ui): display file upload messages" | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit ca814f0 into staging Apr 27, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/invalid-file-types branch April 28, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant