Skip to content

Use correct header for serviceusage API quota - #9832

Merged
joehan merged 3 commits into
mainfrom
jh-firebase-cli-quota-catch
Jan 29, 2026
Merged

joehan merged 3 commits into
mainfrom
jh-firebase-cli-quota-catch

Conversation

@joehan

@joehan joehan commented Jan 28, 2026

Copy link
Copy Markdown
Member

Description

Turns out we were using the wrong header here - x-goog-quota-user is mean to contain a user to charge quota to. For our use case, we need to use x-goog-user-project, per https://docs.cloud.google.com/apis/docs/system-parameters#definitions

I also added a catch to avoid sharing errors that contain the CLI project with end users. These are never actionable by them, and cause support tickets and quota increase requests that never go anywhere.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @joehan, 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 refines how Google Cloud API requests are handled by ensuring the correct x-goog-user-project header is utilized for quota attribution across various services, addressing an identified misconfiguration. Concurrently, it significantly improves the user experience by implementing a robust error handling strategy that intercepts and sanitizes specific internal quota error messages, replacing them with a generic, actionable error. This prevents the leakage of sensitive internal project identifiers and streamlines the support process by avoiding unhelpful error reports.

Highlights

  • Corrected API Quota Header: The pull request updates the Google Cloud API requests to use the x-goog-user-project header instead of x-goog-quota-user. This change ensures that quota usage is correctly attributed to the user's project, aligning with Google Cloud's system parameters documentation.
  • Enhanced Error Handling for Quota Issues: A new error interception mechanism has been implemented to catch specific internal quota errors that might expose sensitive project IDs (e.g., '563584335869'). These errors are now replaced with a generic 'An Internal error has occurred' message, preventing the exposure of internal details to end-users and reducing unactionable support tickets.
  • Updated Test Coverage: New test cases were added to src/apiv2.spec.ts to verify the proper interception and re-throwing of generic errors for specific quota failures. Existing tests in src/ensureApiEnabled.spec.ts and src/gcp/iam.spec.ts were also updated to reflect the change in the quota header from x-goog-quota-user to x-goog-user-project.

🧠 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. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 correctly replaces the x-goog-quota-user header with x-goog-user-project for quota billing, which aligns with the Google API system parameters documentation. The addition of a specific error handler to intercept quota-related errors for the internal CLI project and present a more user-friendly, generic error is a good improvement for user experience, preventing confusing internal details from being exposed. I've left a couple of suggestions to improve maintainability by extracting a hardcoded project ID into a constant. Overall, great work on improving both correctness and user experience.

Comment thread src/apiv2.ts Resolved
Comment thread src/apiv2.spec.ts Resolved
@joehan
joehan requested a review from bkendall January 28, 2026 23:04
@joehan
joehan merged commit 9674e23 into main Jan 29, 2026
@joehan
joehan deleted the jh-firebase-cli-quota-catch branch January 29, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants