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

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

The 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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8c3d3dc-9599-4f27-8008-85bb3eb22e3d
Commits

Reviewing files that changed from the base of the PR and between 63048b7 and a45fc63.

Files selected for processing: 3

  • index.js
  • lib/optionsFromArguments.js
  • spec/test.spec.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@AdrianCurtin
AdrianCurtin force-pushed the fix-file-location-region branch from d8fc90c to a45fc63 Compare November 5, 2026 14:33
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