Skip to content

fix issues around quota project for serviceusage - #9846

Merged
joehan merged 2 commits into
mainfrom
bk-fix-fast
Jan 30, 2026
Merged

joehan merged 2 commits into
mainfrom
bk-fix-fast

Conversation

@bkendall

Copy link
Copy Markdown
Contributor

Description

As it says on the box

Scenarios Tested

Sample Commands

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @bkendall, 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 and resolves issues related to how project identifiers are passed in API requests, particularly for serviceusage and iam operations. It standardizes the format of the x-goog-user-project header to use only the project ID, rather than the projects/{projectId} format, which was causing errors. Additionally, it improves API request logging to include visibility into the x-goog-user-project header when present, enhancing debugging and operational clarity.

Highlights

  • Standardized Project ID Formatting: The pull request standardizes the format for passing project identifiers in API requests, specifically for the x-goog-user-project header and certain resource parameters. It ensures that only the project ID is used, removing the redundant projects/ prefix that was causing issues.
  • Corrected API Calls: Several API calls across iam, serviceusage, and apphosting modules have been updated to correctly format the project ID, resolving underlying issues with these service interactions.
  • Enhanced API Request Logging: The API client's logging mechanism has been improved to include visibility into the x-goog-user-project header, alongside the x-goog-quota-user header, providing better debugging capabilities for API requests.

🧠 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 fixes an issue with the x-goog-user-project header by removing the projects/ prefix from its value across various API calls. This ensures proper quota project attribution. The changes are consistent and include updates to tests. I've included one suggestion to improve the readability of the new logging logic in apiv2.ts.

Comment thread src/apiv2.ts
Comment on lines +541 to 549
const userHeader = headers.has(GOOG_QUOTA_USER_HEADER)
? `${GOOG_QUOTA_USER_HEADER}=${headers.get(GOOG_QUOTA_USER_HEADER)}`
: "";
const projectHeader = headers.has(GOOG_USER_PROJECT_HEADER)
? `${GOOG_USER_PROJECT_HEADER}=${headers.get(GOOG_USER_PROJECT_HEADER)}`
: "";
logger.debug(
`>>> [apiv2][(partial)header] ${options.method} ${logURL} x-goog-quota-user=${
headers.get(GOOG_QUOTA_USER_HEADER) || ""
}`,
`>>> [apiv2][(partial)header] ${options.method} ${logURL} ${userHeader} ${projectHeader}`,
);

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.

medium

This implementation for logging headers can result in extra spaces in the log message if one of the headers is not present. You can make this more robust and readable by building an array of header parts and then joining them.

      const headerParts = [];
      if (headers.has(GOOG_QUOTA_USER_HEADER)) {
        headerParts.push(`${GOOG_QUOTA_USER_HEADER}=${headers.get(GOOG_QUOTA_USER_HEADER)}`);
      }
      if (headers.has(GOOG_USER_PROJECT_HEADER)) {
        headerParts.push(`${GOOG_USER_PROJECT_HEADER}=${headers.get(GOOG_USER_PROJECT_HEADER)}`);
      }
      logger.debug(
        `>>> [apiv2][(partial)header] ${options.method} ${logURL} ${headerParts.join(" ")}`,
      );

@joehan
joehan enabled auto-merge (squash) January 30, 2026 00:31
@joehan
joehan disabled auto-merge January 30, 2026 00:36
@joehan
joehan merged commit a483938 into main Jan 30, 2026
@joehan
joehan deleted the bk-fix-fast branch January 30, 2026 00:37
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