fix(core): ignore GOOGLE_CLOUD_PROJECT for LOGIN_WITH_GOOGLE#26420
fix(core): ignore GOOGLE_CLOUD_PROJECT for LOGIN_WITH_GOOGLE#26420AndyAWD wants to merge 3 commits intogoogle-gemini:mainfrom
Conversation
Fixes google-gemini#19865 Fixes google-gemini#26105 This commit modifies setupUser to ignore the GOOGLE_CLOUD_PROJECT environment variable during the initial Code Assist load for users authenticating via LOGIN_WITH_GOOGLE. This prevents Free Tier users from encountering a 403 Permission Denied error when they have a Vertex project configured in their environment. If a ProjectIdRequiredError is thrown (e.g., for Workspace GCA users), it safely falls back to using the environment variable.
|
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 resolves a 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 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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modifies the setupUser function to handle project ID fallbacks based on the authentication type. Specifically, for LOGIN_WITH_GOOGLE, it now attempts to load user data without a project ID first and falls back to environment variables only if a ProjectIdRequiredError or IneligibleTierError occurs. Comprehensive tests were added to verify this logic. However, the introduction of the AuthType import in setup.ts creates a circular dependency chain (setup.ts -> contentGenerator.ts -> codeAssist.ts -> setup.ts), which can cause runtime issues with undefined exports.
Moves the AuthType enum to a separate file (auth_types.ts) to break the circular import chain between setup.ts, contentGenerator.ts, and codeAssist.ts.
Summary
This PR fixes a bug where users authenticating via
LOGIN_WITH_GOOGLEencounter a403 Permission Deniederror if they haveGOOGLE_CLOUD_PROJECTset in their.envfile. It modifies thesetupUserlogic to temporarily ignore the environment variable during the initial Code Assist API request, allowing Free Tier users to be assigned a server-managed project successfully.Details
authTypedown fromcreateCodeAssistContentGeneratortosetupUser.setupUser:authTypeisLOGIN_WITH_GOOGLE, it attempts to load without a project ID first.ProjectIdRequiredErrororIneligibleTierErroris thrown (e.g., for Workspace GCA users requiring a specific project), it safely falls back to using theenvProjectId.COMPUTE_ADCstrictly use the environment variable immediately without any fallback.setup.test.tsto cover the fallback logic.Related Issues
Fixes #26564
How to Validate
GOOGLE_CLOUD_PROJECT=<any_vertex_project_id>to your~/.gemini/.env.npm startand choose/auth->Sign in with Google.403error.npm run test -w @google/gemini-cli-core.Pre-Merge Checklist