Skip to content

feat(samples): add argparse and clarify traversal support in download_many snippet#1775

Merged
chandra-siri merged 11 commits intomainfrom
update-download-many-snippet
Mar 18, 2026
Merged

feat(samples): add argparse and clarify traversal support in download_many snippet#1775
chandra-siri merged 11 commits intomainfrom
update-download-many-snippet

Conversation

@chandra-siri
Copy link
Collaborator

This PR adds argparse support to the download_many snippet for CLI testing, and updates the description containing traversal safety.

@chandra-siri chandra-siri requested review from a team as code owners March 17, 2026 16:27
@chandra-siri chandra-siri requested review from vchudnov-g and removed request for a team March 17, 2026 16:27
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Mar 17, 2026
@product-auto-label product-auto-label bot added api: storage Issues related to the googleapis/python-storage API. samples Issues that are directly related to samples. labels Mar 17, 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 enhances the storage_transfer_manager_download_many.py sample by introducing command-line argument parsing, which simplifies testing and direct execution. It also improves the clarity and safety documentation around file path handling, ensuring users are aware of how directory traversal is managed during downloads.

Highlights

  • CLI Support: Added argparse integration to the download_many_blobs_with_transfer_manager snippet, enabling command-line execution and testing with specified bucket, blobs, destination directory, and worker count.
  • Traversal Safety Clarification: Updated comments in the download_many_blobs_with_transfer_manager function to explicitly state that the destination_directory parameter now prevents directory traversal outside the specified path, skipping downloads that attempt to do so.
  • Warning Handling: Modified the result processing loop to explicitly handle Warning types, printing a message when a download is skipped due to a warning.
Changelog
  • samples/snippets/storage_transfer_manager_download_many.py
    • Updated comments to clarify directory traversal behavior and the use of pathlib for path construction.
    • Added argparse setup to allow the script to be run directly from the command line with configurable parameters.
    • Modified the download result processing to include handling for Warning instances, alongside Exception and successful downloads.
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 introduces argparse support for the download_many snippet, making it easier to use from the command line. It also updates comments to clarify the handling of directory traversal, improving security awareness. Additionally, the result handling is improved to account for warnings, such as when a download is skipped. My review includes a suggestion to fix an issue in a print statement to ensure the displayed download path is correct.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 17, 2026
@chandra-siri chandra-siri force-pushed the update-download-many-snippet branch from ed16238 to 40157de Compare March 17, 2026 17:20
Base automatically changed from skip_invalid_windows_path to main March 18, 2026 13:40
@chandra-siri chandra-siri requested review from a team as code owners March 18, 2026 13:40
@chandra-siri chandra-siri enabled auto-merge (squash) March 18, 2026 14:35
@chandra-siri chandra-siri merged commit 21bb20f into main Mar 18, 2026
15 checks passed
@chandra-siri chandra-siri deleted the update-download-many-snippet branch March 18, 2026 14:58
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 googleapis/python-storage API. samples Issues that are directly related to samples. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants