Skip to content

Commit db668c6

Browse files
fix(uploads): omit hoisted S3 metadata headers
1 parent c03fc3d commit db668c6

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

apps/sim/lib/uploads/providers/s3/client.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ describe('S3 Client', () => {
247247
})
248248

249249
describe('staged upload primitives', () => {
250-
it('signs a fixed-size PUT with canonical object metadata', async () => {
250+
it('signs metadata without returning duplicate x-amz-meta headers', async () => {
251251
mockGetSignedUrl.mockResolvedValueOnce('https://example.com/signed-put')
252252

253253
const result = await getS3PresignedUploadUrl({
@@ -270,8 +270,6 @@ describe('S3 Client', () => {
270270
url: 'https://example.com/signed-put',
271271
headers: {
272272
'Content-Type': 'application/octet-stream',
273-
'x-amz-meta-uploadid': 'upload-1',
274-
'x-amz-meta-purpose': 'workspace_file',
275273
},
276274
})
277275
})

apps/sim/lib/uploads/providers/s3/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ export async function getPresignedUrlWithConfig(
170170

171171
/**
172172
* Generates a signed single-object PUT for a caller-selected staging key.
173-
* Every returned header covered by the signature must be sent verbatim by the client.
173+
* The AWS presigner hoists `x-amz-meta-*` values into the signed query string,
174+
* so only ordinary transfer headers are returned. Repeating that metadata as
175+
* request headers makes S3 reject the otherwise-valid signature.
174176
*/
175177
export async function getS3PresignedUploadUrl(params: {
176178
key: string
@@ -193,9 +195,6 @@ export async function getS3PresignedUploadUrl(params: {
193195
url,
194196
headers: {
195197
'Content-Type': params.contentType,
196-
...Object.fromEntries(
197-
Object.entries(metadata).map(([key, value]) => [`x-amz-meta-${key.toLowerCase()}`, value])
198-
),
199198
},
200199
}
201200
}

0 commit comments

Comments
 (0)