Skip to content

fix: Bucket region is ignored, breaking access to buckets in opt-in regions - #594

Open
AdrianCurtin wants to merge 1 commit into
parse-community:masterfrom
AdrianCurtin:fix-file-location-region
Open

fix: Bucket region is ignored, breaking access to buckets in opt-in regions#594
AdrianCurtin wants to merge 1 commit into
parse-community:masterfrom
AdrianCurtin:fix-file-location-region

Conversation

@AdrianCurtin

@AdrianCurtin AdrianCurtin commented Aug 13, 2026

Copy link
Copy Markdown

Issue

Closes: #139
Closes: #595

A bucket in a region that is not enabled by default, ap-east-1 in 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. getFileLocation returned https://<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. optionsFromArguments copies an explicit list of fields out of the options object for the string and positional forms, and region is the only field in the defaults list that is missing from that copy list. It silently fell back to us-east-1:

new S3Adapter('key', 'secret', 'bucket', { region: 'ap-east-1' })._region  // us-east-1
new S3Adapter('bucket', { region: 'ap-east-1' })._region                   // us-east-1
new S3Adapter({ bucket: 'bucket', region: 'ap-east-1' })._region           // ap-east-1

Approach

The url now carries the region, and region is 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 directAccess without a baseUrl, from <bucket>.s3.amazonaws.com to <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 whether presignedUrl was 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-1 without 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 with PermanentRedirect, so such a setup is generally already broken.

Tests

  • A direct access url for a bucket in ap-east-1, the case from the report.
  • The region surviving each constructor form, and still defaulting when the options object omits it.
  • Three existing direct access assertions updated to the regional host.

Full suite passes.

Related pull requests

These all touch createFile or getFileLocation in index.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

#336 and #594 conflict with nothing. The rest collide on the createFile prologue and on the same anchor in spec/test.spec.js, where the conflict truncates each side's block, so the incoming describe has to be re-inserted whole rather than resolved line by line.

#593 and #594 now overlap. Both write the direct access host in getFileLocation, #594 as https://${bucket}.s3.${region}.amazonaws.com and #593 as _buildLocationBase(), and both update the three should go directly to amazon assertions. Keep _buildLocationBase(), which already includes the region and additionally handles custom endpoints. Same behavior for the default case, so the resolution is mechanical.

@parse-github-assistant

Copy link
Copy Markdown

🚀 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

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

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.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@AdrianCurtin, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e2a7dd4-6747-4321-b9b0-9e6dcb7d93f4

📥 Commits

Reviewing files that changed from the base of the PR and between b9245cb and bb8422d.

📒 Files selected for processing (3)
  • index.js
  • lib/optionsFromArguments.js
  • spec/test.spec.js

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configured region is ignored in the string and positional constructor forms Adapter does't work with ap-east-1 (HK)

1 participant