Skip to content

Conversation

@shubhangi-google
Copy link
Owner

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rake ci in the gem subdirectory.
  • Update code documentation if necessary.

closes: #<issue_number_goes_here>

@gemini-code-assist
Copy link

Summary of Changes

Hello @shubhangi-google, 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 refines the file upload mechanism within the Google Cloud Storage Ruby client library by introducing crc32c as the default checksum for new file creations when no other checksum is specified. It also addresses a potential resource management issue in checksum calculation for StringIO inputs, ensuring that file handles are always properly closed. These changes aim to improve the robustness and default behavior of file uploads, supported by comprehensive new and updated test cases.

Highlights

  • Default CRC32c Checksum: The create_file method in Bucket now automatically applies a crc32c checksum by default if no checksum, crc32c, or md5 is explicitly provided during file creation.
  • Resource Management for Checksums: The md5_for and crc32c_for methods in File::Verifier have been enhanced to ensure proper closing of file handles when processing StringIO objects that might internally open temporary files, preventing potential resource leaks.
  • Expanded Test Coverage: New tests have been added to bucket_test.rb and lazy/bucket_test.rb to specifically validate the new default crc32c checksum behavior for both Tempfile and StringIO inputs.
  • Test Helper Alignment: The empty_file_gapi helper methods in various test files were updated to reflect the new default crc32c checksum behavior, ensuring test consistency.
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

@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

Thank you for this contribution. The changes to set a default checksum and fix checksum calculation for file paths are well-implemented and include relevant tests. My review primarily focuses on improving the long-term maintainability of the code by addressing several instances of code duplication that were introduced. I've provided specific suggestions to refactor this duplicated logic into shared methods and test modules.

@shubhangi-google
Copy link
Owner Author

/gemini review

Copy link

@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 a default checksum (:crc32c) for file creation, which is a good improvement for data integrity. The changes in bucket.rb and the associated test files are correct and properly test the new behavior. However, the refactoring of the checksum calculation logic in google/cloud/storage/file/verifier.rb has introduced a performance issue for file paths provided as strings and has made the code harder to understand. I've provided a detailed comment with a suggested replacement for the _digest_for method that is both more performant and easier to maintain.

@shubhangi-google shubhangi-google changed the base branch from main to setting_default_checksum October 15, 2025 12:28
@shubhangi-google shubhangi-google changed the base branch from setting_default_checksum to main October 15, 2025 12:30
@shubhangi-google shubhangi-google changed the base branch from main to setting_default_checksum October 15, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants