Uh oh!
There was an error while loading. Please reload this page.
fix(uploads): write workspaceFiles row when issuing presigned URL - #4537
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Tests were extended to mock Reviewed by Cursor Bugbot for commit c89ef33. Configure here. |
Greptile SummaryThis PR fixes image preview authorization failures in Mothership/execution/workspace-logos flows by writing the
Confidence Score: 5/5Safe to merge — the change is a targeted hotfix that adds three DB writes at presign time, each gated behind the existing permission checks, with the same error-handling path as the rest of the route. The logic is straightforward: insert a DB row after a successful presigned URL generation so downstream serve requests can authorize. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant PresignedRoute as /api/files/presigned
participant S3 as S3/Blob Storage
participant DB as workspaceFiles (DB)
participant ServeRoute as /api/files/serve
Client->>PresignedRoute: "POST ?type=mothership|execution|workspace-logos"
PresignedRoute->>S3: generatePresignedUploadUrl()
S3-->>PresignedRoute: "{ url, key }"
PresignedRoute->>DB: "insertFileMetadata({ key, context, userId, workspaceId, ... })"
DB-->>PresignedRoute: FileMetadataRecord
PresignedRoute-->>Client: "{ presignedUrl, fileInfo.key, ... }"
Client->>S3: PUT (presigned URL) - actual file upload
S3-->>Client: 200 OK
Client->>ServeRoute: "GET /api/files/serve/s3/:key?context=mothership"
ServeRoute->>DB: getFileMetadataByKey(key)
DB-->>ServeRoute: FileMetadataRecord (row exists - authorized)
ServeRoute->>S3: downloadFile(key)
S3-->>ServeRoute: file bytes
ServeRoute-->>Client: file response
Reviews (2): Last reviewed commit: "test(uploads): cover insertFileMetadata ..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 9, 2026
waleedlatif1
commented
May 9, 2026
@cursor review |
There was a problem hiding this comment.
✅ 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 c89ef33. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Summary
workspaceFilesrow at presign time, matching whatstorageService.uploadFiledoes on mainFileNotFoundErrorfrom/api/files/servebecause no DB row existed and S3HeadObjectreturned lowercased metadata keysType of Change
Testing
Tested manually on staging — dropped image into Mothership chat, clicked preview, image renders.
bun run check:api-validationpasses; new and existing tests pass.Checklist