Repository navigation
fix: Bucket region is ignored, breaking access to buckets in opt-in regions - #594
AdrianCurtin 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 reachedThe included review limit has been reached and this organization has disabled usage-based review continuation. Wait for reviews to reset or ask a billing admin to change After included review limits. Next included review available in 59 minutes. View limit details
|
bb8422d to
d8fc90c
Compare
d8fc90c to
a45fc63
Compare
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.