This repository was archived by the owner on Mar 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 394
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
file download mutates options arguments #2667
Copy link
Copy link
Closed
Labels
api: storageIssues related to the googleapis/nodejs-storage API.Issues related to the googleapis/nodejs-storage API.
Description
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
A screenshot that you have tested with "Try this API".
The issue is client side, not in the API
![]()
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
Line 2322 in e0ac235
| delete options.destination; |
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
The options object argument in the download method is mutated after use of the function.
import { Storage } from "@google-cloud/storage";
const storageOptions = {
keyFilename: process.env.DEV_STORAGE_GOOGLE_APPLICATION_CREDENTIALS,
};
const storage = new Storage(storageOptions);
const options = {
destination: `./cat.jpg`,
};
console.log(`Image will be downloaded to destination: ${options.destination}`);
try {
const file = await storage
.bucket('1337-bucket')
.file('myDemoKey')
.download(options); // This downloads the file to the specified destination
} catch (error) {
console.error('Error downloading file... this is PoC bucket does not exist'); // Doesn't really matter
}
console.log(`Image downloaded to destination: ${options.destination}`); // <-- This won't work because Google has a nasty bug in @google-cloud/storage ...This is similar to the closed issue #1891 that I was able to find.
Line 2322 in e0ac235
| delete options.destination; |
A clear and concise description of what the bug is, and what you expected to happen.
Passing object to a function should not have a side effect of removing keys from the options object.
It can cause a lot of issues and bugs down the line.
A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
There is no documentation that points to this as it is unintended side-effect.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/nodejs-storage API.Issues related to the googleapis/nodejs-storage API.