Skip to content

WIP: refactor(storage): standardize buckets error handling (nodejs-storage migration)#4256

Draft
angelcaamal wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
angelcaamal:chore/storage-samples-migration
Draft

WIP: refactor(storage): standardize buckets error handling (nodejs-storage migration)#4256
angelcaamal wants to merge 4 commits intoGoogleCloudPlatform:mainfrom
angelcaamal:chore/storage-samples-migration

Conversation

@angelcaamal
Copy link
Contributor

Description

Fixes #b/489802539

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

Wrapped async calls in try...catch blocks, standardized error logging, and ensured strict mode/unhandledRejection fallbacks are present across all bucket samples.
@product-auto-label product-auto-label bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Mar 13, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the Node.js samples for Google Cloud Storage, offering developers a rich set of examples for interacting with GCS buckets and objects. The new samples cover a broad spectrum of features, from basic CRUD operations to advanced security and performance configurations, aiming to provide clear and practical guidance for common use cases. The inclusion of new system tests reinforces the quality and accuracy of these examples.

Highlights

  • Comprehensive Node.js Samples for Cloud Storage: This pull request introduces a vast collection of new Node.js samples demonstrating a wide range of Google Cloud Storage functionalities, including bucket and file ACLs, lifecycle management, encryption, HMAC keys, notifications, and advanced transfer operations.
  • Enhanced Error Handling and Migration Focus: The changes are part of a broader effort to standardize error handling within Cloud Storage samples and facilitate migration to updated Node.js client library practices.
  • New System Tests for Robustness: Accompanying the new samples are extensive system tests covering various aspects of bucket and file management, IAM, encryption, and transfer manager functionalities, ensuring the reliability and correctness of the provided examples.
  • Transfer Manager Integration: Several new samples specifically highlight the use of the Transfer Manager for efficient parallel uploads and downloads of multiple files and directories, as well as chunked file transfers.
Changelog
  • storage/README.md
    • Added an auto-generated README file detailing all available Node.js samples for Google Cloud Storage.
  • storage/addBucketConditionalBinding.js
    • Added a new sample to demonstrate adding conditional IAM bindings to a bucket.
  • storage/addBucketDefaultOwnerAcl.js
    • Added a new sample for setting a default owner ACL on a bucket.
  • storage/addBucketIamMember.js
    • Added a new sample to show how to add an IAM member to a bucket.
  • storage/addBucketLabel.js
    • Added a new sample for adding labels to a bucket.
  • storage/addBucketOwnerAcl.js
    • Added a new sample for adding an owner ACL to a bucket.
  • storage/addBucketWebsiteConfiguration.js
    • Added a new sample to configure website settings for a bucket.
  • storage/addFileOwnerAcl.js
    • Added a new sample for adding an owner ACL to a file.
  • storage/bucketMetadata.js
    • Added a new sample to retrieve bucket metadata.
  • storage/changeDefaultStorageClass.js
    • Added a new sample to change a bucket's default storage class.
  • storage/changeFileCSEKToCMEK.js
    • Added a new sample to convert a file's Customer-Supplied Encryption Key (CSEK) to a Customer-Managed Encryption Key (CMEK).
  • storage/composeFile.js
    • Added a new sample to combine multiple files into a single new file.
  • storage/configureBucketCors.js
    • Added a new sample to configure CORS settings for a bucket.
  • storage/configureRetries.js
    • Added a new sample demonstrating how to configure retry options for storage operations.
  • storage/copyFile.js
    • Added a new sample for copying a file.
  • storage/copyOldVersionOfFile.js
    • Added a new sample to copy an old version of a file.
  • storage/createBucketWithDualRegion.js
    • Added a new sample to create a dual-region bucket.
  • storage/createBucketWithHierarchicalNamespace.js
    • Added a new sample to create a bucket with hierarchical namespace enabled.
  • storage/createBucketWithObjectRetention.js
    • Added a new sample to create a bucket with object retention enabled.
  • storage/createBucketWithStorageClassAndLocation.js
    • Added a new sample to create a bucket with a specific storage class and location.
  • storage/createBucketWithTurboReplication.js
    • Added a new sample to create a bucket with Turbo Replication enabled.
  • storage/createNewBucket.js
    • Added a new sample for creating a new bucket.
  • storage/createNotification.js
    • Added a new sample to create bucket notifications.
  • storage/deleteBucket.js
    • Added a new sample for deleting a bucket.
  • storage/deleteFile.js
    • Added a new sample for deleting a file.
  • storage/deleteNotification.js
    • Added a new sample to delete bucket notifications.
  • storage/deleteOldVersionOfFile.js
    • Added a new sample to delete an old version of a file.
  • storage/disableBucketLifecycleManagement.js
    • Added a new sample to disable bucket lifecycle management.
  • storage/disableBucketVersioning.js
    • Added a new sample to disable bucket versioning.
  • storage/disableDefaultEventBasedHold.js
    • Added a new sample to disable default event-based holds on a bucket.
  • storage/disableRequesterPays.js
    • Added a new sample to disable requester pays for a bucket.
  • storage/disableSoftDelete.js
    • Added a new sample to disable soft delete policy for a bucket.
  • storage/disableUniformBucketLevelAccess.js
    • Added a new sample to disable uniform bucket-level access.
  • storage/downloadByteRange.js
    • Added a new sample to download a specific byte range of a file.
  • storage/downloadEncryptedFile.js
    • Added a new sample to download an encrypted file.
  • storage/downloadFile.js
    • Added a new sample for downloading a file.
  • storage/downloadFileInChunksWithTransferManager.js
    • Added a new sample to download a file in chunks using Transfer Manager.
  • storage/downloadFileUsingRequesterPays.js
    • Added a new sample to download a file using requester pays.
  • storage/downloadFolderWithTransferManager.js
    • Added a new sample to download a folder using Transfer Manager.
  • storage/downloadIntoMemory.js
    • Added a new sample to download a file's contents directly into memory.
  • storage/downloadManyFilesWithTransferManager.js
    • Added a new sample to download multiple files using Transfer Manager.
  • storage/downloadPublicFile.js
    • Added a new sample to download a publicly accessible file.
  • storage/enableBucketLifecycleManagement.js
    • Added a new sample to enable bucket lifecycle management.
  • storage/enableBucketVersioning.js
    • Added a new sample to enable bucket versioning.
  • storage/enableDefaultEventBasedHold.js
    • Added a new sample to enable default event-based holds on a bucket.
  • storage/enableDefaultKMSKey.js
    • Added a new sample to enable a default KMS key for a bucket.
  • storage/enableRequesterPays.js
    • Added a new sample to enable requester pays for a bucket.
  • storage/enableUniformBucketLevelAccess.js
    • Added a new sample to enable uniform bucket-level access.
  • storage/fileChangeStorageClass.js
    • Added a new sample to change a file's storage class.
  • storage/fileSetMetadata.js
    • Added a new sample to set metadata for a file.
  • storage/generateEncryptionKey.js
    • Added a new sample to generate an encryption key.
  • storage/generateSignedUrl.js
    • Added a new sample to generate a V2 signed URL for a file.
  • storage/generateV4ReadSignedUrl.js
    • Added a new sample to generate a V4 signed URL for reading a file.
  • storage/generateV4SignedPolicy.js
    • Added a new sample to generate a V4 signed policy for uploading files via HTML forms.
  • storage/generateV4UploadSignedUrl.js
    • Added a new sample to generate a V4 signed URL for uploading a file.
  • storage/getAutoclass.js
    • Added a new sample to retrieve autoclass settings for a bucket.
  • storage/getDefaultEventBasedHold.js
    • Added a new sample to get the default event-based hold status of a bucket.
  • storage/getMetadata.js
    • Added a new sample to retrieve file metadata.
  • storage/getMetadataNotifications.js
    • Added a new sample to get metadata for bucket notifications.
  • storage/getPublicAccessPrevention.js
    • Added a new sample to get the public access prevention status of a bucket.
  • storage/getRPO.js
    • Added a new sample to get the Recovery Point Objective (RPO) for a bucket.
  • storage/getRequesterPaysStatus.js
    • Added a new sample to get the requester pays status of a bucket.
  • storage/getRetentionPolicy.js
    • Added a new sample to get the retention policy of a bucket.
  • storage/getServiceAccount.js
    • Added a new sample to retrieve the Google Cloud Storage service account email.
  • storage/getSoftDeletePolicy.js
    • Added a new sample to get the soft delete policy of a bucket.
  • storage/getSoftDeletedBucket.js
    • Added a new sample to get a soft-deleted bucket.
  • storage/getUniformBucketLevelAccess.js
    • Added a new sample to get the uniform bucket-level access status of a bucket.
  • storage/hmacKeyActivate.js
    • Added a new sample to activate an HMAC service account key.
  • storage/hmacKeyCreate.js
    • Added a new sample to create an HMAC service account key.
  • storage/hmacKeyDeactivate.js
    • Added a new sample to deactivate an HMAC service account key.
  • storage/hmacKeyDelete.js
    • Added a new sample to delete an HMAC service account key.
  • storage/hmacKeyGet.js
    • Added a new sample to get metadata for an HMAC service account key.
  • storage/hmacKeysList.js
    • Added a new sample to list HMAC service account keys.
  • storage/listBuckets.js
    • Added a new sample to list all buckets.
  • storage/listBucketsPartialSuccess.js
    • Added a new sample to list buckets with partial success handling.
  • storage/listFiles.js
    • Added a new sample to list files in a bucket.
  • storage/listFilesByPrefix.js
    • Added a new sample to list files by a specified prefix.
  • storage/listFilesPaginate.js
    • Added a new sample to list files with pagination.
  • storage/listFilesWithOldVersions.js
    • Added a new sample to list files including their old versions.
  • storage/listNotifications.js
    • Added a new sample to list all bucket notifications.
  • storage/listSoftDeletedBucket.js
    • Added a new sample to list soft-deleted buckets.
  • storage/listSoftDeletedObjectVersions.js
    • Added a new sample to list soft-deleted object versions.
  • storage/listSoftDeletedObjects.js
    • Added a new sample to list soft-deleted objects.
  • storage/lockRetentionPolicy.js
    • Added a new sample to lock a bucket's retention policy.
  • storage/makeBucketPublic.js
    • Added a new sample to make a bucket publicly readable.
  • storage/makePublic.js
    • Added a new sample to make a file publicly readable.
  • storage/moveFile.js
    • Added a new sample to move a file within a bucket.
  • storage/moveFileAtomic.js
    • Added a new sample to atomically move a file within a bucket.
  • storage/package.json
    • Updated dependencies to include @google-cloud/pubsub, @google-cloud/storage, node-fetch, uuid, yargs, chai, mocha, and p-limit.
  • storage/printBucketAcl.js
    • Added a new sample to print the ACL for a bucket.
  • storage/printBucketAclForUser.js
    • Added a new sample to print a specific user's ACL for a bucket.
  • storage/printFileAcl.js
    • Added a new sample to print the ACL for a file.
  • storage/printFileAclForUser.js
    • Added a new sample to print a specific user's ACL for a file.
  • storage/quickstart.js
    • Added a new quickstart sample for Google Cloud Storage.
  • storage/releaseEventBasedHold.js
    • Added a new sample to release an event-based hold on a file.
  • storage/releaseTemporaryHold.js
    • Added a new sample to release a temporary hold on a file.
  • storage/removeBucketConditionalBinding.js
    • Added a new sample to remove conditional IAM bindings from a bucket.
  • storage/removeBucketCors.js
    • Added a new sample to remove CORS configuration from a bucket.
  • storage/removeBucketDefaultOwner.js
    • Added a new sample to remove a default owner from a bucket's ACL.
  • storage/removeBucketIamMember.js
    • Added a new sample to remove an IAM member from a bucket.
  • storage/removeBucketLabel.js
    • Added a new sample to remove labels from a bucket.
  • storage/removeBucketOwnerAcl.js
    • Added a new sample to remove an owner from a bucket's ACL.
  • storage/removeDefaultKMSKey.js
    • Added a new sample to remove a default KMS key from a bucket.
  • storage/removeFileOwnerAcl.js
    • Added a new sample to remove an owner from a file's ACL.
  • storage/removeRetentionPolicy.js
    • Added a new sample to remove a bucket's retention policy.
  • storage/renameFile.js
    • Added a new sample to rename a file.
  • storage/resources/.gitignore
    • Added a gitignore file to exclude downloaded test files.
  • storage/resources/resourcesSub1/testSub1.txt
    • Added a sample text file for testing directory uploads.
  • storage/resources/test.txt
    • Added a sample text file for various file operations.
  • storage/resources/test2.txt
    • Added another sample text file for various file operations.
  • storage/restoreSoftDeletedBucket.js
    • Added a new sample to restore a soft-deleted bucket.
  • storage/restoreSoftDeletedObject.js
    • Added a new sample to restore a soft-deleted object.
  • storage/rotateEncryptionKey.js
    • Added a new sample to rotate a file's encryption key.
  • storage/scripts/cleanup
    • Added a script to clean up storage buckets created during tests.
  • storage/setAutoclass.js
    • Added a new sample to set autoclass settings for a bucket.
  • storage/setClientEndpoint.js
    • Added a new sample to set a custom client endpoint for Storage operations.
  • storage/setEventBasedHold.js
    • Added a new sample to set an event-based hold on a file.
  • storage/setObjectRetentionPolicy.js
    • Added a new sample to set the object retention policy for a file.
  • storage/setPublicAccessPreventionEnforced.js
    • Added a new sample to enforce public access prevention for a bucket.
  • storage/setPublicAccessPreventionInherited.js
    • Added a new sample to set public access prevention to inherited for a bucket.
  • storage/setRPOAsyncTurbo.js
    • Added a new sample to set Recovery Point Objective (RPO) to ASYNC_TURBO for a bucket.
  • storage/setRPODefault.js
    • Added a new sample to set Recovery Point Objective (RPO) to DEFAULT for a bucket.
  • storage/setRetentionPolicy.js
    • Added a new sample to set a retention policy for a bucket.
  • storage/setSoftDeletePolicy.js
    • Added a new sample to set a soft delete policy for a bucket.
  • storage/setTemporaryHold.js
    • Added a new sample to set a temporary hold on a file.
  • storage/streamFileDownload.js
    • Added a new sample to stream file downloads.
  • storage/streamFileUpload.js
    • Added a new sample to stream file uploads.
  • storage/system-test/acl.test.js
    • Added system tests for ACL operations.
  • storage/system-test/bucketLifecycle.test.js
    • Added system tests for bucket lifecycle management.
  • storage/system-test/bucketLock.test.js
    • Added system tests for bucket lock operations.
  • storage/system-test/buckets.test.js
    • Added system tests for various bucket operations.
  • storage/system-test/encryption.test.js
    • Added system tests for encryption-related operations.
  • storage/system-test/files.test.js
    • Added system tests for file operations.
  • storage/system-test/hmacKey.test.js
    • Added system tests for HMAC key management.
  • storage/system-test/iam.test.js
    • Added system tests for IAM operations.
  • storage/system-test/notifications.test.js
    • Added system tests for bucket notifications.
  • storage/system-test/quickstart.test.js
    • Added system tests for the quickstart sample.
  • storage/system-test/requesterPays.test.js
    • Added system tests for requester pays functionality.
  • storage/system-test/storage.test.js
    • Added system tests for general storage client functionality.
  • storage/system-test/transfer-manager.test.js
    • Added system tests for Transfer Manager operations.
  • storage/uploadDirectory.js
    • Added a new sample to upload an entire directory.
  • storage/uploadDirectoryWithTransferManager.js
    • Added a new sample to upload a directory using Transfer Manager.
  • storage/uploadEncryptedFile.js
    • Added a new sample to upload an encrypted file.
  • storage/uploadFile.js
    • Added a new sample for uploading a file.
  • storage/uploadFileInChunksWithTransferManager.js
    • Added a new sample to upload a file in chunks using Transfer Manager.
  • storage/uploadFileWithKmsKey.js
    • Added a new sample to upload a file with a KMS key.
  • storage/uploadFromMemory.js
    • Added a new sample to upload file contents from memory.
  • storage/uploadManyFilesWithTransferManager.js
    • Added a new sample to upload multiple files using Transfer Manager.
  • storage/uploadWithoutAuthentication.js
    • Added a new sample for unauthenticated file uploads.
  • storage/uploadWithoutAuthenticationSignedUrl.js
    • Added a new sample for unauthenticated file uploads using signed URLs.
  • storage/viewBucketIamMembers.js
    • Added a new sample to view IAM members for a bucket.
Activity
  • The pull request is currently marked as 'WIP' (Work In Progress), indicating ongoing development.
  • The author has included a comprehensive checklist in the PR description, tracking progress on tests, linting, CI, and other necessary requirements.
  • The title suggests this PR is part of a larger 'nodejs-storage migration' effort, implying a strategic update to the Node.js storage samples.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a comprehensive suite of new samples for the Google Cloud Storage Node.js client library. While the additions are extensive, there are several areas for improvement to ensure consistency and correctness across the new files. The primary issue is the lack of standardized error handling, with a mix of try...catch blocks and generic .catch() handlers. Additionally, a global unhandledRejection handler is missing in some files, and where suggested, it should be adjusted to only log errors without explicitly terminating the process, aligning with repository guidelines. I've also identified several typos in filenames and parameter names within the sample-metadata usage instructions and the main README.md, as well as a recurring typo in code comments. Addressing these points will significantly improve the quality and maintainability of these new samples.

__Usage:__


`node hmacKeyList.js [projectId]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. The script is named hmacKeysList.js, but it's referenced here as hmacKeyList.js.

Suggested change
`node hmacKeyList.js [projectId]`
`node hmacKeysList.js [projectId]`

__Usage:__


`node removeBucketLabel.js <BUCKET_NAME> labelone)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. It should be <LABEL_KEY> instead of labelone) to accurately reflect the parameter.

Suggested change
`node removeBucketLabel.js <BUCKET_NAME> labelone)`
`node removeBucketLabel.js <BUCKET_NAME> <LABEL_KEY>`

__Usage:__


`node files.js upload-directory <bucketName> <directoryPath>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The usage example appears to be incorrect. Based on the script's implementation, it should be invoked directly, not as a command of files.js.

Suggested change
`node files.js upload-directory <bucketName> <directoryPath>`
`node uploadDirectory.js <bucketName> <directoryPath>`

__Usage:__


`node uploadFolderWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. The script is named uploadDirectoryWithTransferManager.js, but it's referenced here as uploadFolderWithTransferManager.js.

Suggested change
`node uploadFolderWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>`
`node uploadDirectoryWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>`

Comment on lines +59 to +98
async function addBucketConditionalBinding() {
// Get a reference to a Google Cloud Storage bucket
const bucket = storage.bucket(bucketName);

// Gets and updates the bucket's IAM policy
const [policy] = await bucket.iam.getPolicy({requestedPolicyVersion: 3});

// Set the policy's version to 3 to use condition in bindings.
policy.version = 3;

// Adds the new roles to the bucket's IAM policy
policy.bindings.push({
role: roleName,
members: members,
condition: {
title: title,
description: description,
expression: expression,
},
});

// Updates the bucket's IAM policy
await bucket.iam.setPolicy(policy);

console.log(
`Added the following member(s) with role ${roleName} to ${bucketName}:`
);

members.forEach(member => {
console.log(` ${member}`);
});

console.log('with condition:');
console.log(` Title: ${title}`);
console.log(` Description: ${description}`);
console.log(` Expression: ${expression}`);
}

addBucketConditionalBinding().catch(console.error);
// [END storage_add_bucket_conditional_iam_binding]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To standardize error handling and provide more descriptive error messages, please wrap the logic inside addBucketConditionalBinding in a try...catch block. This is inconsistent with other new samples like addBucketLabel.js which use this pattern.

  async function addBucketConditionalBinding() {
    try {
      // Get a reference to a Google Cloud Storage bucket
      const bucket = storage.bucket(bucketName);

      // Gets and updates the bucket's IAM policy
      const [policy] = await bucket.iam.getPolicy({requestedPolicyVersion: 3});

      // Set the policy's version to 3 to use condition in bindings.
      policy.version = 3;

      // Adds the new roles to the bucket's IAM policy
      policy.bindings.push({
        role: roleName,
        members: members,
        condition: {
          title: title,
          description: description,
          expression: expression,
        },
      });

      // Updates the bucket's IAM policy
      await bucket.iam.setPolicy(policy);

      console.log(
        `Added the following member(s) with role ${roleName} to ${bucketName}:`
      );

      members.forEach(member => {
        console.log(`  ${member}`);
      });

      console.log('with condition:');
      console.log(`  Title: ${title}`);
      console.log(`  Description: ${description}`);
      console.log(`  Expression: ${expression}`);
    } catch (error) {
      console.error(
        'Error executing add bucket conditional binding:',
        error.message || error
      );
    }
  }

  addBucketConditionalBinding();
  // [END storage_add_bucket_conditional_iam_binding]

disableSoftDelete();
// [END storage_disable_soft_delete]
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other samples and to ensure unhandled promise rejections are caught, please add a process.on('unhandledRejection', ...) handler. Ensure that the handler only logs the error and does not explicitly terminate the process, aligning with the guideline to prevent unexpected process termination.

Suggested change
process.on('unhandledRejection', err => {
console.error(err.message);
});
main(...process.argv.slice(2));
References
  1. Avoid calling process.exit() inside main functions. Instead, log errors using console.error to prevent unexpected process termination and maintain consistency with other samples.

// sample-metadata:
// title: List HMAC SA Keys Metadata.
// description: List HMAC SA Keys Metadata.
// usage: node hmacKeyList.js [projectId]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. The filename is hmacKeysList.js, but the usage instruction refers to hmacKeyList.js.

Suggested change
// usage: node hmacKeyList.js [projectId]
// usage: node hmacKeysList.js [projectId]

// sample-metadata:
// title: Storage Remove Bucket Label.
// description: Removes bucket label.
// usage: node removeBucketLabel.js <BUCKET_NAME> labelone)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. It should be <LABEL_KEY> instead of labelone) to match the function parameter and be more descriptive.

Suggested change
// usage: node removeBucketLabel.js <BUCKET_NAME> labelone)
// usage: node removeBucketLabel.js <BUCKET_NAME> <LABEL_KEY>

// sample-metadata:
// title: Upload a directory to a bucket.
// description: Uploads full hierarchy of a local directory to a bucket.
// usage: node files.js upload-directory <bucketName> <directoryPath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The usage example appears to be incorrect. It should likely be node uploadDirectory.js <bucketName> <directoryPath> to match how the script is invoked.

Suggested change
// usage: node files.js upload-directory <bucketName> <directoryPath>
// usage: node uploadDirectory.js <bucketName> <directoryPath>

// sample-metadata:
// title: Upload Directory With Transfer Manager
// description: Uploads a directory in parallel utilizing transfer manager.
// usage: node uploadFolderWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the usage example. The filename is uploadDirectoryWithTransferManager.js, but it's referenced here as uploadFolderWithTransferManager.js.

Suggested change
// usage: node uploadFolderWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>
// usage: node uploadDirectoryWithTransferManager.js <BUCKET_NAME> <DIRECTORY_NAME>

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

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant