fix (telemetry): inject quota_project_id to prevent fallback to default oauth client#26698
Conversation
…back to default oauth client
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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 addresses a PERMISSION_DENIED error encountered during telemetry trace exporting. By explicitly providing a quota_project_id in the authentication credentials, the change ensures that API requests are correctly attributed to the user's project rather than falling back to the default OAuth client project, which lacks the necessary Cloud Trace API permissions. Highlights
Using Gemini Code AssistThe 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
Customization To customize the 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 Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds the quota_project_id to the OAuth2 credentials object to prevent trace export fallbacks to the default client. The review feedback suggests improving the environment variable fallback logic by including GOOGLE_CLOUD_PROJECT_ID for consistency with other parts of the core package and removing redundant nullish coalescing.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Issue
When running the CLI with telemetry enabled, trace exporting fails with the following error:
Root Cause
When creating the
jwtInputcredentials object, thequota_project_idis not specified. As a result, when the trace exporter sends data, the GCP gateway triggers a fallback mechanism. It parses the token, identifies project681255809395(the official Gemini CLI public OAuth project) as the issuer, and attempts to deduct the API quota from it. Since Cloud Trace API is not enabled for that public project, the request is instantly rejected.Fix
Injected
quota_project_idinto thejwtInputobject using a robust fallback strategy:This approach achieves two things:
GOOGLE_CLOUD_PROJECT), establishing a correct billing attribution and resolving thePERMISSION_DENIEDissue.GOOGLE_CLOUD_QUOTA_PROJECTfirst, it perfectly preserves GCP's architecture capability, allowing enterprise users to explicitly decouple resource and quota projects if needed.Fixes #21969