Repository navigation
[3.x] Validate the deployment bucket region when HeadBucket is forbidden - #472
Merged
Merged
Conversation
GrahamCampbell
force-pushed
the
fix-forbidden-head-bucket-3x
branch
from
October 24, 2026 22:45
2c44536 to
f31115b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the 3.x port of #471. Since #113 the custom deployment bucket is checked with HeadBucket, which S3 authorizes as s3:ListBucket without an s3:prefix, so a deploy role whose ListBucket permission is limited to its own prefix of a shared bucket gets a 403 for a bucket it can deploy to, and the deploy fails with a misleading "Could not locate deployment bucket" error, as @danielnc diagnosed in #463.
S3 returns the x-amz-bucket-region header on a forbidden HeadBucket response, and the v2 SDK exposes it as the region property of the error. This change uses that region when the request fails, only throws the not-found error when no region is known, and leaves the existing comparison to reject a bucket in another region. A missing bucket still fails with the not-found error, since a 404 carries no region header.