Skip to content

fix (telemetry): inject quota_project_id to prevent fallback to default oauth client#26698

Merged
scidomino merged 5 commits into
google-gemini:mainfrom
TNTCompany:fix/telemetry-quota-project-fallback
May 12, 2026
Merged

fix (telemetry): inject quota_project_id to prevent fallback to default oauth client#26698
scidomino merged 5 commits into
google-gemini:mainfrom
TNTCompany:fix/telemetry-quota-project-fallback

Conversation

@TNTCompany
Copy link
Copy Markdown
Contributor

@TNTCompany TNTCompany commented May 8, 2026

Issue

When running the CLI with telemetry enabled, trace exporting fails with the following error:

PERMISSION_DENIED: Cloud Trace API has not been used in project 681255809395 before or it is disabled.

Root Cause

When creating the jwtInput credentials object, the quota_project_id is not specified. As a result, when the trace exporter sends data, the GCP gateway triggers a fallback mechanism. It parses the token, identifies project 681255809395 (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_id into the jwtInput object using a robust fallback strategy:

quota_project_id: process.env['GOOGLE_CLOUD_QUOTA_PROJECT'] || process.env['GOOGLE_CLOUD_PROJECT'] || undefined

This approach achieves two things:

  1. Sane Default: By default, it allows users to align the quota project with their environment (GOOGLE_CLOUD_PROJECT), establishing a correct billing attribution and resolving the PERMISSION_DENIED issue.
  2. Maintains Decoupling: By checking GOOGLE_CLOUD_QUOTA_PROJECT first, it perfectly preserves GCP's architecture capability, allowing enterprise users to explicitly decouple resource and quota projects if needed.

Fixes #21969

@TNTCompany TNTCompany requested a review from a team as a code owner May 8, 2026 11:58
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 8, 2026

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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

  • Telemetry Fix: Injected the quota_project_id into the jwtInput object to prevent incorrect quota attribution during trace exporting.
  • Environment Configuration: Implemented a fallback strategy using GOOGLE_CLOUD_QUOTA_PROJECT and GOOGLE_CLOUD_PROJECT environment variables to ensure correct billing and API access.
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 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 .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 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

  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
Copy Markdown
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 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.

Comment thread packages/core/src/code_assist/oauth2.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label May 8, 2026
@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/enterprise Issues related to Telemetry, Policy, Quota / Licensing and removed status/need-issue Pull requests that need to have an associated issue. labels May 9, 2026
@scidomino scidomino enabled auto-merge May 12, 2026 16:19
@scidomino scidomino added this pull request to the merge queue May 12, 2026
Merged via the queue into google-gemini:main with commit bc730b2 May 12, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/enterprise Issues related to Telemetry, Policy, Quota / Licensing priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traces exporting doesn't work with CliAuth

2 participants