Skip to content

fix(s3): return BucketAlreadyOwnedByYou for an existing bucket - #1663

Open
hsusul wants to merge 2 commits into
supabase:masterfrom
hsusul:fix/s3-bucket-already-owned-by-you
Open

hsusul wants to merge 2 commits into
supabase:masterfrom
hsusul:fix/s3-bucket-already-owned-by-you

Conversation

@hsusul

@hsusul hsusul commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Why

S3 CreateBucket on a bucket that already exists in the project returns BucketAlreadyExists. Amazon S3 returns BucketAlreadyOwnedByYou when the caller owns the bucket, and the Storage bucket namespace is per project. Clients that treat that code as "already created" fail instead.

Fixes #1656.

What changed

Scope

Only the S3 protocol code for this one case changes. The REST API keeps BucketAlreadyExists.

Verification

  • npm run test:unit -- src/storage/protocols/s3/s3-handler.test.ts failed at the test commit with Expected "BucketAlreadyOwnedByYou", Received "BucketAlreadyExists", then passed all 88 tests with the fix. Full npm run test:unit passed 3,485 tests.
  • formatS3ErrorResponse on the handler's error now gives Code: BucketAlreadyOwnedByYou instead of BucketAlreadyExists.
  • npm run lint and npm run build passed. Integration tests were not run.

@hsusul
hsusul requested a review from a team as a code owner November 4, 2026 17:53
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 41881508237

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.004%) to 87.245%

Details

  • Coverage increased (+0.004%) from the base build.
  • Patch coverage: 7 of 7 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15844
Covered Lines: 14268
Line Coverage: 90.05%
Relevant Branches: 10083
Covered Branches: 8352
Branch Coverage: 82.83%
Branches in Coverage %: Yes
Coverage Strength: 1256.25 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 CreateBucket returns BucketAlreadyExists for a bucket the project already owns

2 participants