Skip to content

Comments

chore: Lint changes#1761

Draft
chandra-siri wants to merge 7 commits intomainfrom
lint_changes
Draft

chore: Lint changes#1761
chandra-siri wants to merge 7 commits intomainfrom
lint_changes

Conversation

@chandra-siri
Copy link
Collaborator

chore: Lint changes

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/python-storage API. labels Feb 24, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chandra-siri, 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 primarily focuses on enhancing the asynchronous gRPC client's flexibility for testing purposes and refining the conformance test suite. It introduces the ability to create insecure gRPC clients with anonymous credentials, which is then utilized to refactor existing bidirectional read and write conformance tests to use pytest-asyncio. Additionally, a critical fix for x-goog-request-params header formatting ensures correct request handling, alongside general code cleanup and formatting improvements.

Highlights

  • AsyncGrpcClient Refactoring: The AsyncGrpcClient has been refactored to support initialization with AnonymousCredentials and to create insecure gRPC channels, primarily to facilitate testing against local testbenches.
  • Conformance Test Migration: Bidirectional read and write conformance tests have been updated to leverage pytest-asyncio and the newly introduced insecure gRPC client creation methods, improving test infrastructure.
  • Request Parameter Formatting Fix: The x-goog-request-params header formatting in async read and write object streams was corrected to use an ampersand (&) as a delimiter instead of a comma (,), resolving a potential issue with request parsing.
  • Testing Utilities and Dependencies: A new utility function start_grpc_server was added to manage the gRPC testbench server for conformance tests, and pytest-asyncio was added as a development dependency.
  • Code Formatting and Linting: Various files received minor formatting and linting adjustments to improve code consistency and readability.
Changelog
  • google/cloud/storage/asyncio/async_appendable_object_writer.py
    • Updated metadata parameter name from metadata to current_metadata in the open method for consistency.
  • google/cloud/storage/asyncio/async_grpc_client.py
    • Imported grpc and google.auth.credentials.
    • Modified the __init__ method to handle AnonymousCredentials by creating an insecure client.
    • Added _create_anonymous_client method to construct a gRPC client with anonymous credentials and an insecure channel.
    • Added _create_insecure_grpc_client class method for convenient creation of an insecure client for testing.
  • google/cloud/storage/asyncio/async_read_object_stream.py
    • Changed the delimiter for x-goog-request-params from a comma (,) to an ampersand (&).
  • google/cloud/storage/asyncio/async_write_object_stream.py
    • Changed the delimiter for x-goog-request-params from a comma (,) to an ampersand (&).
  • noxfile.py
    • Added pytest-asyncio to the conftest_retry session installation list.
  • tests/conformance/_utils.py
    • Added a new file containing the start_grpc_server function to ensure the testbench gRPC server is running for conformance tests.
  • tests/conformance/test_bidi_reads.py
    • Removed asyncio import and added client_options, AsyncGrpcClient, pytest, and start_grpc_server imports.
    • Refactored run_test_scenario to initialize AsyncMultiRangeDownloader with an insecure AsyncGrpcClient.
    • Converted main function to test_bidi_reads using pytest.mark.asyncio and integrated start_grpc_server.
    • Commented out a test scenario related to 'Smarter Resumption: Retry 503 after partial data'.
    • Updated run_open_test_scenario to use the insecure AsyncGrpcClient.
  • tests/conformance/test_bidi_writes.py
    • Removed asyncio import and added pytest, client_options, AsyncGrpcClient, and start_grpc_server imports.
    • Refactored run_test_scenario to initialize AsyncAppendableObjectWriter with an insecure AsyncGrpcClient.
    • Converted main function to test_bidi_writes using pytest.mark.asyncio and integrated start_grpc_server.
    • Commented out test scenarios related to 'Smarter Resumption' and 'Default Policy: Smarter Ressumption'.
  • tests/perf/microbenchmarks/_utils.py
    • Applied minor formatting to comments and multiline assertions.
    • Adjusted whitespace around operators.
  • tests/perf/microbenchmarks/time_based/conftest.py
    • Applied minor formatting to string literals.
  • tests/perf/microbenchmarks/time_based/reads/test_reads.py
    • Removed an unnecessary blank line.
  • tests/unit/asyncio/test_async_appendable_object_writer.py
    • Applied minor formatting to improve readability of recv.return_value assignments.
    • Adjusted line breaks for multiline assertions in test_append.
  • tests/unit/asyncio/test_async_grpc_client.py
    • Imported client_options.
    • Refactored test_grpc_client_with_anon_creds to directly mock grpc.aio.insecure_channel and use client_options.
    • Simplified _make_credentials usage in test_delete_object, test_get_object, and test_get_object_with_all_parameters.
Activity
  • The pull request was created with the title 'Lint changes' and description 'chore: Lint changes', indicating an initial focus on code quality and maintenance.
  • The author, chandra-siri, implemented changes across several files, including core client logic, stream handling, and test infrastructure.
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.

@chandra-siri chandra-siri changed the title Lint changes chore: Lint changes Feb 24, 2026
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 aims to introduce support for anonymous and insecure gRPC clients, alongside linting and bug fixes, including a fix in AsyncAppendableObjectWriter. However, it introduces significant security concerns by forcing the use of insecure gRPC channels (without TLS) for anonymous credentials and creating potential parameter injection vulnerabilities in the x-goog-request-params header due to unescaped user-supplied values. Furthermore, the AsyncGrpcClient's anonymous client implementation has a potential AttributeError if client_options is not provided, and it skips client_info initialization. Several conformance test cases were also commented out without explanation, and the PR title 'Lint changes' is misleading given these functional and security-related modifications.

I am having trouble creating individual review comments. Click here to see my feedback.

google/cloud/storage/asyncio/async_grpc_client.py (57-61)

security-medium medium

This block forces the use of an insecure gRPC channel via grpc.aio.insecure_channel when AnonymousCredentials are provided, disabling TLS encryption and posing a security risk for production. This should not be the default behavior for anonymous connections. Furthermore, it skips client_info initialization, resulting in missing user-agent or library version metadata, and risks an AttributeError if client_options is None when _create_anonymous_client accesses api_endpoint.

google/cloud/storage/asyncio/async_grpc_client.py (80)

security-medium medium

The use of grpc.aio.insecure_channel creates a gRPC channel without SSL/TLS encryption, exposing transmitted data to interception. Insecure channels should be explicitly opted into, not forced. Furthermore, the _create_anonymous_client method requires robustness improvements: it should validate client_options before accessing api_endpoint, pass client_info and client_options to the StorageAsyncClient constructor for consistency, and consider using storage_v2.StorageAsyncClient.get_transport_class("grpc_asyncio") for maintainability.

google/cloud/storage/asyncio/async_read_object_stream.py (118)

security-medium medium

The x-goog-request-params header is constructed by joining parameters with & without escaping the values. The bucket parameter is derived from self.bucket_name, which is user-supplied. If a bucket name contains characters like & or =, an attacker can inject arbitrary parameters into the header. This header is used by Google Cloud infrastructure for request routing and other critical decisions. All values should be URL-encoded before being joined into the header string.

google/cloud/storage/asyncio/async_write_object_stream.py (148)

security-medium medium

The x-goog-request-params header is constructed by joining parameters with & without escaping the values. The bucket parameter is derived from self.bucket_name, which is user-supplied. If a bucket name contains characters like & or =, an attacker can inject arbitrary parameters into the header. This header is used by Google Cloud infrastructure for request routing and other critical decisions. All values should be URL-encoded before being joined into the header string.

tests/conformance/test_bidi_reads.py (135-140)

medium

This test case for 'Smarter Resumption' has been commented out. Disabling conformance tests should be avoided unless there is a specific reason (e.g., a known issue with the testbench). If it must be disabled, please add a comment explaining why and include a TODO to re-enable it.

tests/conformance/test_bidi_writes.py (185-190)

medium

This test case for 'Smarter Resumption' has been commented out. Please provide a reason for disabling this test or re-enable it if it was done accidentally.

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. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant