fix(s3): include Region in isSameAuth to prevent cross-region CopyObject failures#337
Merged
Merged
Conversation
…ect failures isSameAuth only compared AccessKeyID, RoleARN, and SessionToken, so same-credential copies between buckets in different AWS regions were treated as same-auth and routed through the server-side CopyObject API. AWS rejects that call with PermanentRedirect when source and target regions differ. Region is now part of the comparison so these copies correctly fall back to the client-side TouchCopyBuffered path.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes cross-region S3 copy behavior by ensuring server-side CopyObject is only attempted when the source and target S3 filesystems are configured for the same AWS region, avoiding PermanentRedirect failures and falling back to client-side buffered copying when regions differ.
Changes:
- Updated
isSameAuthto includeRegionin the auth-equivalence check. - Added unit tests validating same-credentials cross-region copies return
false, while same-region returnstrue. - Documented the fix in
CHANGELOG.mdunder[Unreleased].
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CHANGELOG.md | Adds an Unreleased “Fixed” entry describing the S3 cross-region copy behavior change. |
| backend/s3/file.go | Includes Region in isSameAuth to prevent cross-region server-side CopyObject usage. |
| backend/s3/file_test.go | Extends TestIsSameAuth with region-based cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The prior comment described AccessKeyID/SessionToken as "mutually exclusive" and implied nil values, which doesn't match the string Options fields. Reworded to describe the actual comparison and why Region must match.
dustin-schnee
approved these changes
Jul 1, 2026
funkyshu
approved these changes
Jul 1, 2026
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.
Summary
isSameAuthinbackend/s3/file.goonly comparedAccessKeyID,RoleARN, andSessionToken, so same-credential copies between buckets in different AWS regions were treated as same-auth and routed through the server-sideCopyObjectAPI.PermanentRedirect(HTTP 301) when source and target regions differ, sinceCopyObjectis invoked via the source region's endpoint.Regionis now part of theisSameAuthcomparison, so same-credential, different-region copies correctly fall back to the client-sideTouchCopyBufferedpath, which uses each filesystem's own regional client.Test plan
false) and same-credentials/same-region (expecttrue) cases inTestIsSameAuthgo test ./backend/s3/...passesgolangci-lint run ./backend/s3/...passes cleanCHANGELOG.mdunder[Unreleased]per repo conventions