chore(storage): add DirectPath diagnostic info in gRPC request header#14126
Merged
cpriti-os merged 13 commits intogoogleapis:mainfrom Mar 11, 2026
Merged
chore(storage): add DirectPath diagnostic info in gRPC request header#14126cpriti-os merged 13 commits intogoogleapis:mainfrom
cpriti-os merged 13 commits intogoogleapis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds diagnostic information for DirectPath to the gRPC request headers, introducing a new mechanism to determine why DirectPath might not be used and report it. However, a security concern has been identified: a debug statement using fmt.Printf logs potentially sensitive request headers to stdout, which could lead to information disclosure in production environments. Additionally, the code has a few other issues: significant code duplication between GetDirectPathDiagnostic and directPathDiagnostic, inconsistent return values for diagnostic functions, and an opportunity to simplify error handling logic.
This refactors the auth diagnostic to use `internaloption.UnsafeResolver` instead of `internal.DialSettings` and `internal.Creds()`, removing the dependency on `google.golang.org/api/internal`. It now relies on the `cloud.google.com/go/compute/metadata` package explicitly to verify if a service account is attached and a token can be fetched. It also upgrades `google.golang.org/api` to `main` to support the latest methods added to `UnsafeResolver` and adds comprehensive unit tests with a mocked metadata server for the diagnostic function. Co-authored-by: cpriti-os <202586561+cpriti-os@users.noreply.github.com>
This refactors the auth diagnostic to use `internaloption.UnsafeResolver` instead of `internal.DialSettings` and `internal.Creds()`, removing the dependency on `google.golang.org/api/internal`. It now relies on the `cloud.google.com/go/compute/metadata` package explicitly to verify if a default service account is attached and a token can be fetched. It removes outdated diagnostic reasons that relied on internal APIs and adds `reasonCustomHTTPClient` and `reasonUndetermined`. It also upgrades `google.golang.org/api` to `main` to support the latest methods added to `UnsafeResolver` and adds comprehensive unit tests with a mocked metadata server for the diagnostic function. Co-authored-by: cpriti-os <202586561+cpriti-os@users.noreply.github.com>
krishnamd-jkp
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.