fix: Bucket region is ignored, breaking access to buckets in opt-in regions - #594
fix: Bucket region is ignored, breaking access to buckets in opt-in regions#594AdrianCurtin wants to merge 1 commit into
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
Warning Review limit reached
Next review available in: 20 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Issue
Closes: #139
Closes: #595
A bucket in a region that is not enabled by default,
ap-east-1in the report, uploads fine but the url handed back is unusable. The configured region was being lost in two independent places, and the issue only closes when both are fixed.The direct access url omitted the region.
getFileLocationreturnedhttps://<bucket>.s3.amazonaws.com/<key>. The global endpoint does not reach buckets in opt-in regions, so the url resolves to nothing for exactly the regions in the report.The region never arrived in the first place, for two of the three constructor forms.
optionsFromArgumentscopies an explicit list of fields out of the options object for the string and positional forms, andregionis the only field in the defaults list that is missing from that copy list. It silently fell back tous-east-1:Approach
The url now carries the region, and
regionis copied like every other option. All four forms, including the default, resolve correctly after the change.Compatibility
Two behavior changes worth stating rather than leaving to be discovered.
The direct access url changes host for every deployment using
directAccesswithout abaseUrl, from<bucket>.s3.amazonaws.comto<bucket>.s3.<region>.amazonaws.com. Both forms work for regions enabled by default, so this is not a break, but it is visible to anyone pinning that hostname in a CDN origin or a CORS allowlist. Three existing assertions are updated accordingly.This is better read as removing an inconsistency than as inventing a url shape: the presigned test already expected
my-bucket.s3.us-east-1.amazonaws.com, because the SDK builds that url itself. The same adapter was returning two different hosts for the same object depending on whetherpresignedUrlwas set. They now agree.The options fix changes where the S3 client points, not just a url. Anyone who declared a non-default region through the string or positional form has been running against
us-east-1without knowing, and will now get the region they asked for. That is the intent, but it is a change for a configuration that was silently wrong. The exposed population should be very small, since writing to the wrong region fails withPermanentRedirect, so such a setup is generally already broken.Tests
ap-east-1, the case from the report.Full suite passes.
Related pull requests
These all touch
createFileorgetFileLocationinindex.js. Merging them in this order leaves the fewest conflicts, verified by trial merges of all six together, which pass the suite once resolved:#336 → #594 → #597 → #591 → #593 → #242
generateKeyLocationurlLocationomitted the bucket for custom endpointscreateFilereporting the stored name and url#336 and #594 conflict with nothing. The rest collide on the
createFileprologue and on the same anchor inspec/test.spec.js, where the conflict truncates each side's block, so the incomingdescribehas to be re-inserted whole rather than resolved line by line.