Skip to content

feat(storage): add sample for hierarchical namespace recursive delete - #4434

Draft
nidhiii-27 wants to merge 7 commits into
mainfrom
feat/add-node-delete-folder-recursive
Draft

feat(storage): add sample for hierarchical namespace recursive delete#4434
nidhiii-27 wants to merge 7 commits into
mainfrom
feat/add-node-delete-folder-recursive

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Draft PR for hierarchical namespace recursive delete folder sample.

[Generated-by: AI]

Adds a Node.js code sample demonstrating hierarchical namespace recursive folder delete.

Fixes: b/530059535

[Generated-by: AI]
Add helpful log statements.
…ests

Re-enable recursive delete folder integration tests and resolve GCS billing project limitations.

[Generated-by: AI]
Remove skip comment for 'should delete a folder recursively' integration test.

[Generated-by: AI]
@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 Aug 29, 2026

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

Copy link
Copy Markdown
Contributor

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 introduces a new sample script deleteFolderRecursive.js to recursively delete folders, updates renameFolder.js to strip billing project headers, bumps the @google-cloud/storage-control dependency, and updates system tests to explicitly pass the project ID to the Storage client. It also enables the folder renaming test and adds a test for recursive deletion. Regarding the feedback, there is an issue in deleteFolderRecursive.js where a failed operation is incorrectly logged as successful; the code should check for op.error and throw an error if the operation fails.

);
op = latestOp;
}
console.log(`Deleted folder: ${folderName}.`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

If the recursive delete operation fails, op.done will be true but op.error will be populated. Currently, the code will incorrectly log that the folder was successfully deleted even if the operation failed. We should check for op.error and throw an error if it exists.

    if (op.error) {
      throw new Error(op.error.message);
    }
    console.log("Deleted folder: " + folderName + ".");

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