Repository navigation
Validate the deployment bucket region when HeadBucket is forbidden - #471
Merged
Merged
Conversation
GrahamCampbell
force-pushed
the
fix-forbidden-head-bucket
branch
from
October 24, 2026 21:50
56dbfa2 to
2221378
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.
Since #113 the custom deployment bucket is checked with HeadBucket, which S3 authorizes as s3:ListBucket without an s3:prefix. A deploy role whose ListBucket permission is limited to its own prefix of a shared bucket therefore 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 catch block already reads it, but then throws the not-found error even when the region matches. This change only throws not-found when the region is unknown, and leaves the existing comparison after the try to reject a bucket in another region. A missing bucket still fails with the not-found error, since a 404 carries no region header. The 3.x branch has the same problem and can be fixed the same way through the region the v2 SDK sets on the error.
This supersedes #463, which added a GetBucketLocation fallback that needs a second request and the s3:GetBucketLocation permission.