Skip to content

fix(file-upload): workspace/chat context not being passed in some forms - #1852

Merged
icecrasher321 merged 1 commit into
stagingfrom
fix/context-workspace-fileupload
Nov 8, 2025
Merged

fix(file-upload): workspace/chat context not being passed in some forms#1852
icecrasher321 merged 1 commit into
stagingfrom
fix/context-workspace-fileupload

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Pass storage context in form based callsites correctly.

Type of Change

  • Bug fix

Testing

Tested with @aadamgough

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)

@vercel

vercelBot commented Nov 8, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 8, 2025 2:05am

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes a critical bug where the context parameter was missing from FormData uploads in fallback paths when presigned URLs are unavailable. The /api/files/upload endpoint requires an explicit context parameter to determine proper file storage routing and permissions.

Key Changes:

  • Added context: 'chat' to FormData in use-image-upload.ts (chat deploy hook)
  • Added context: 'chat' to FormData in image-selector.tsx (chat logo selector)
  • Added context: 'workspace' to FormData in file-upload.tsx (workflow block file uploads)

Impact:

  • Without this fix, fallback uploads would fail with error: "Upload requires explicit context parameter"
  • The primary presigned URL path already correctly passes type=chat query parameter, so this only affects the fallback scenario
  • Ensures consistent storage routing for both direct uploads and API fallback uploads

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are minimal, focused, and fix a clear bug. Each addition correctly matches the required context for the specific upload scenario (chat vs workspace). The fix aligns with the existing codebase pattern where other upload locations already include the context parameter. No logical errors, security issues, or unintended side effects were found.
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/chat-deploy/hooks/use-image-upload.ts5/5Added missing context: 'chat' parameter to FormData for fallback upload path, ensuring proper file storage routing
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/control-bar/components/deploy-modal/components/image-selector/image-selector.tsx5/5Added missing context: 'chat' parameter to FormData for fallback upload path, ensuring proper file storage routing
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/file-upload.tsx5/5Added missing context: 'workspace' parameter to FormData for file uploads, ensuring proper file storage routing with workspace-scoped storage

Sequence Diagram

sequenceDiagram
participant User
participant ImageUpload as Image Upload Component
participant Presigned as /api/files/presigned
participant CloudStorage as Cloud Storage
participant Upload as /api/files/upload
participant Storage as Storage Service
User->>ImageUpload: Select/Upload Image
Note over ImageUpload,Presigned: Primary Path: Direct Upload
ImageUpload->>Presigned: POST with type=chat/workspace
alt Cloud Storage Available
Presigned-->>ImageUpload: Presigned URL + key
ImageUpload->>CloudStorage: PUT file to presigned URL
CloudStorage-->>ImageUpload: Upload success
else No Cloud Storage / Presigned Fails
Note over ImageUpload,Upload: Fallback Path (Fixed in this PR)
ImageUpload->>Upload: POST with FormData
Note right of ImageUpload: BEFORE: Missing context<br/>AFTER: Includes context='chat'/'workspace'
Upload->>Upload: Validate context parameter (required)
Upload->>Storage: Upload with context
Storage-->>Upload: File info with path
Upload-->>ImageUpload: Success response
end
ImageUpload-->>User: Display uploaded image
Loading

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
icecrasher321 merged commit c8ea08e into stagingNov 8, 2025
9 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/context-workspace-fileupload branch November 8, 2025 23:27
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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

@icecrasher321