Skip to content

Conversation

@scotthart
Copy link
Member

No description provided.

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Jan 14, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @scotthart, 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 refactors the authentication infrastructure within the Google Cloud C++ client library for Google Cloud Storage. The primary goal is to consolidate authentication logic by removing GCS-specific OAuth2 implementations and fully adopting the unified google::cloud::Credentials interface. This change simplifies the codebase, enhances maintainability, and provides a more consistent developer experience across Google Cloud services. Additionally, it introduces a convenient new method for initializing service account credentials directly from file paths.

Highlights

  • Decommissioned GCS-specific OAuth2 API: The entire google::cloud::storage::oauth2 namespace and its associated credential implementations have been removed, streamlining the authentication layer.
  • Transition to Unified Credentials: The Google Cloud Storage (GCS) client library now exclusively utilizes the unified google::cloud::Credentials API for all authentication mechanisms, reducing code duplication and improving consistency.
  • New Service Account Credentials from File API: A new public API, MakeServiceAccountCredentialsFromFile, has been introduced in the unified credentials library, enabling the creation of service account credentials directly from a file path.
  • Enhanced Internal Credential Handling: Internal gRPC and REST credential visitors have been updated to seamlessly process service account configurations provided via file paths, ensuring consistent behavior across different transports.
  • Removed Oauth2CredentialsOption: The GCS-specific Oauth2CredentialsOption has been removed from the client options, with UnifiedCredentialsOption now serving as the standard for credential configuration.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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

This pull request decommissions the GCS-specific OAuth2 API, replacing it with a unified credentials implementation. This is a significant and positive refactoring that centralizes authentication logic. The changes are extensive, involving the removal of many old credential-related files and updating call sites to use the new APIs. My review found a couple of places where error handling for file operations could be improved to provide better diagnostics. Otherwise, the changes look correct and consistent with the goal of the PR.

Comment on lines +119 to +122
std::ifstream is(*cfg.file_path());
std::string contents(std::istreambuf_iterator<char>{is}, {});
result = std::make_unique<GrpcServiceAccountAuthentication>(
std::move(contents), std::move(options));

Choose a reason for hiding this comment

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

high

There's no error handling here if the file specified by cfg.file_path() cannot be opened. If std::ifstream fails to open the file, it will be in a bad state, and reading from it will produce an empty string. This will likely cause a JSON parsing error later, which can be misleading. It would be better to check if the file was opened successfully and return a specific error if it was not.

        std::ifstream is(*cfg.file_path());
        if (!is) {
          result = std::make_unique<GrpcErrorAuthentication>(
              google::cloud::internal::UnknownError(
                  "Cannot open credentials file " + *cfg.file_path(),
                  GCP_ERROR_INFO()));
          return;
        }
        std::string contents(std::istreambuf_iterator<char>{is}, {});
        result = std::make_unique<GrpcServiceAccountAuthentication>(
            std::move(contents), std::move(options));

Comment on lines 77 to 80
std::ifstream is(path);
std::string contents(std::istreambuf_iterator<char>{is}, {});
return CreateServiceAccountCredentialsFromJsonContents(
std::move(contents), options, std::move(client_factory));

Choose a reason for hiding this comment

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

high

Similar to another part of this PR, there's no error handling if the file at path cannot be opened. If std::ifstream fails, it enters a bad state, and contents will be an empty string. This will lead to a less specific error message down the line. It's better to check for file opening success and return an error immediately.

  std::ifstream is(path);
  if (!is) {
    return google::cloud::internal::UnknownError(
        "Cannot open credentials file " + path, GCP_ERROR_INFO());
  }
  std::string contents(std::istreambuf_iterator<char>{is}, {});
  return CreateServiceAccountCredentialsFromJsonContents(
      std::move(contents), options, std::move(client_factory));

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

❌ Patch coverage is 82.63473% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.82%. Comparing base (c201e56) to head (dc982cb).

Files with missing lines Patch % Lines
...oud/internal/oauth2_service_account_credentials.cc 70.73% 12 Missing ⚠️
...ts/service_account_credentials_integration_test.cc 0.00% 10 Missing ⚠️
.../cloud/storage/benchmarks/throughput_experiment.cc 0.00% 5 Missing ⚠️
google/cloud/internal/unified_rest_credentials.cc 86.66% 2 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           prepare-for-v3.0.0   #15883      +/-   ##
======================================================
- Coverage               92.87%   92.82%   -0.05%     
======================================================
  Files                    2391     2360      -31     
  Lines                  218434   216573    -1861     
======================================================
- Hits                   202866   201041    -1825     
+ Misses                  15568    15532      -36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart force-pushed the v3_storage_use_unified_creds branch from dc982cb to 3e9ad21 Compare January 16, 2026 01:03
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant