Skip to content

fix(s3): enforce UploadPartCopy source preconditions - #1494

Open
hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/upload-part-copy-preconditions
Open

hsusul wants to merge 1 commit into
supabase:masterfrom
hsusul:fix/upload-part-copy-preconditions

Conversation

@hsusul

@hsusul hsusul commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1493.

UploadPartCopy accepted x-amz-copy-source-if-match, x-amz-copy-source-if-none-match, x-amz-copy-source-if-modified-since, and x-amz-copy-source-if-unmodified-since, then copied the source anyway. The handler dropped the headers, so the file backend wrote the part and the S3 backend never sent them to UploadPartCopy. A failed precondition also reserved multipart progress because that reservation happened before the copy.

This rejects a failed precondition before reserving progress, and forwards the headers on the S3 backend. CopyObject already enforced the same headers (#1406); this is the UploadPartCopy path.

Test plan

  • src/storage/backend/file.test.ts — mismatched if-match returns 412 and does not write the part; a matching ETag copies the bytes
  • src/storage/backend/s3/adapter.test.ts — preconditions are set on UploadPartCopyCommand
  • src/storage/protocols/s3/s3-handler.test.ts — a failed if-match returns 412 before the progress transaction
  • npm run lint
  • npm run build
  • Integration tests (npm run test:integration) require Docker and Postgres and were not run

UploadPartCopy accepted x-amz-copy-source-if-* and copied the source anyway. Reject a failed precondition before reserving progress, and forward the headers to the S3 backend.

Fixes supabase#1493
@hsusul
hsusul requested a review from a team as a code owner October 9, 2026 04:46
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37885456270

Coverage decreased (-0.07%) to 84.873%

Details

  • Coverage decreased (-0.07%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (30 of 34 lines covered, 88.24%).
  • 17 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
src/storage/backend/s3/adapter.ts 7 3 42.86%
Total (4 files) 34 30 88.24%

Coverage Regressions

17 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/internal/http/agent.ts 17 32.56%

Coverage Stats

Coverage Status
Relevant Lines: 14545
Covered Lines: 12793
Line Coverage: 87.95%
Relevant Branches: 8989
Covered Branches: 7181
Branch Coverage: 79.89%
Branches in Coverage %: Yes
Coverage Strength: 784.45 hits per line

💛 - Coveralls

This branch has not been deployed

No deployments
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.

S3 UploadPartCopy ignores x-amz-copy-source-if-* preconditions

2 participants