New Issue Checklist
Issue Description
region passed in the options object is silently discarded when the adapter is constructed with the string or positional forms. The adapter falls back to us-east-1, so both the S3 client and the generated file urls address the wrong region, with no warning.
optionsFromArguments copies an explicit list of fields out of the options object for those two forms:
if (otherOptions) {
options.bucketPrefix = otherOptions.bucketPrefix;
options.credentials = otherOptions.credentials;
options.directAccess = otherOptions.directAccess;
// ...
}
region is the only field in the defaults list further down that is missing from that copy list, so it never survives to fromEnvironmentOrDefault(options, 'region', 'S3_REGION', DEFAULT_S3_REGION) and takes the default.
Steps to reproduce
new S3Adapter('key', 'secret', 'bucket', { region: 'ap-east-1' })._region;
new S3Adapter('bucket', { region: 'ap-east-1' })._region;
new S3Adapter({ bucket: 'bucket', region: 'ap-east-1' })._region;
Actual Outcome
| Constructor form |
_region |
('key', 'secret', 'bucket', { region }) |
us-east-1 |
('bucket', { region }) |
us-east-1 |
({ bucket, region }) |
ap-east-1 |
Expected Outcome
All three resolve to ap-east-1. region should behave like every other option, explicit value first, then S3_REGION, then the default.
Notes
The failure is silent, which is what makes it costly to diagnose. A bucket outside us-east-1 rejects writes with PermanentRedirect, and the reporter of #139 is a plausible instance: uploads worked, so their region did reach the client, meaning they used the object form or S3_REGION, while anyone on the positional form would see a different and more confusing failure.
Found while fixing #139. Both are the same underlying symptom, the configured region not being honored, so they are fixed together in the PR that closes this.
Environment
Adapter version: master, current lib/optionsFromArguments.js.
New Issue Checklist
Issue Description
regionpassed in the options object is silently discarded when the adapter is constructed with the string or positional forms. The adapter falls back tous-east-1, so both the S3 client and the generated file urls address the wrong region, with no warning.optionsFromArgumentscopies an explicit list of fields out of the options object for those two forms:regionis the only field in the defaults list further down that is missing from that copy list, so it never survives tofromEnvironmentOrDefault(options, 'region', 'S3_REGION', DEFAULT_S3_REGION)and takes the default.Steps to reproduce
Actual Outcome
_region('key', 'secret', 'bucket', { region })us-east-1('bucket', { region })us-east-1({ bucket, region })ap-east-1Expected Outcome
All three resolve to
ap-east-1.regionshould behave like every other option, explicit value first, thenS3_REGION, then the default.Notes
The failure is silent, which is what makes it costly to diagnose. A bucket outside
us-east-1rejects writes withPermanentRedirect, and the reporter of #139 is a plausible instance: uploads worked, so their region did reach the client, meaning they used the object form orS3_REGION, while anyone on the positional form would see a different and more confusing failure.Found while fixing #139. Both are the same underlying symptom, the configured region not being honored, so they are fixed together in the PR that closes this.
Environment
Adapter version:
master, currentlib/optionsFromArguments.js.