Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Fixes #2838
This PR resolves a
403 PERMISSION_DENIEDerror for Gemini CLI users who are authenticated with a personal Google (OAuth) account (i.e., not using a GCP project).The root cause was that the
discoverProjectIdfunction insrc/api/providers/gemini-cli.tswas incorrectly falling back to a project ID of"default", which is invalid and promptly rejected by the Google API.Implementation
The implementation is a one-line change in
src/api/providers/gemini-cli.ts.I modified the
initialProjectIdvariable assignment to use an empty string ("") as the fallback instead of"default".Before:
After:
Using an empty string correctly signals to the Google API to use the project-less personal authentication flow. This fixes the error without breaking the TypeScript type contract or requiring any other refactoring.
How to Test
This test requires authenticating with the Gemini CLI using the personal "Login with Google" (OAuth) method.
Prerequisite: Ensure you are not authenticated with a GCP project.
GOOGLE_CLOUD_PROJECTenvironment variable is unset.~/.gemini/.envfile, ensure it does not containGOOGLE_CLOUD_PROJECT.To see the bug (on
mainbranch):403 PERMISSION_DENIEDerror notification.To test the fix (on this PR branch):
fix/gemini-cli-default-project).F5).