Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The createBucket method is mutating the object passed as parameter #3013

Closed
3 tasks done
eaviles opened this issue Dec 18, 2019 · 2 comments
Closed
3 tasks done

The createBucket method is mutating the object passed as parameter #3013

eaviles opened this issue Dec 18, 2019 · 2 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.

Comments

@eaviles
Copy link

eaviles commented Dec 18, 2019

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
The createBucket method in AWS.S3 is mutating the object passed as parameter.

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v12.13.0

SDK version number
v2.585.0

To Reproduce (observed behavior)

const params = { Bucket: 'sample' };
await client.createBucket(params).promise();

After running the above core, the value of params is now:

{
  Bucket: 'sample',
  CreateBucketConfiguration: { LocationConstraint: 'us-east-1' }
}

Which causes problems if someone is reusing the same object in a different call, for example:

await client.waitFor('bucketExists', params).promise();
// which throws: [UnexpectedParameter] Unexpected key 'CreateBucketConfiguration' found in params

Expected behavior
After calling createBucket, the original object used as parameter shouldn't be mutated.

Workaround
Freezing the object before passing it as parameter seems to stop this behavior.

const params = Object.freeze({ Bucket: 'sample' });
await client.createBucket(params).promise();
await client.waitFor('bucketExists', params).promise();

As modules don't run in strict mode by default, the attempt to change the original object won't throw an exception and will just be ignored.

@eaviles eaviles added the bug This issue is a bug. label Dec 18, 2019
@eaviles eaviles changed the title The createBucket is mutating the object passed as parameter The createBucket method is mutating the object passed as parameter Dec 18, 2019
@ajredniwja
Copy link
Contributor

Hey @eaviles, thank-you for reaching out to us with your issue.

I was not able to reproduce behavior can you please share how you are providing the region for your use case?

@ajredniwja ajredniwja added guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. closing-soon This issue will automatically close in 4 days unless further comments are made. and removed bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Dec 19, 2019
@lock
Copy link

lock bot commented Jan 4, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

2 participants