Skip to content

feat(vertex): add vertexLocation config setting for Vertex AI region override#25362

Draft
Famous077 wants to merge 33 commits intogoogle-gemini:mainfrom
Famous077:feat/vertex-ai-location-override
Draft

feat(vertex): add vertexLocation config setting for Vertex AI region override#25362
Famous077 wants to merge 33 commits intogoogle-gemini:mainfrom
Famous077:feat/vertex-ai-location-override

Conversation

@Famous077
Copy link
Copy Markdown
Contributor

Summary

When using Gemini CLI with Vertex AI, requests are routed to us-central1 by
default. The problem is that preview/experimental models like
gemini-3.1-pro-preview are only released to the global region first, so
anyone trying to use them gets an immediate 404 error with no clear explanation
of why.

This PR adds a vertexLocation setting to settings.json so users can
override the region without having to set environment variables every session.

Details

The root cause was twofold:

  1. googleCloudLocation was being read from the GOOGLE_CLOUD_LOCATION env
    var but never actually stored into ContentGeneratorConfig — so even if
    users set the env var correctly, it wasn't always being honored in the Vertex
    AI auth path.

  2. There was no persistent way to set the location. Users had to remember to
    export GOOGLE_CLOUD_LOCATION in every terminal session.

The fix wires vertexLocation from settings.json through the full config
pipeline — ConfigParametersConfig class getter →
createContentGeneratorConfigGoogleGenAI client. Settings take priority
over the env var, but the env var still works as a fallback so nothing is
broken for existing users.

Also fixed 15 pre-existing TypeScript errors in shell.test.ts where
invocation.execute() was being called with a raw AbortSignal instead of
the expected ExecuteOptions object — this was breaking the build on a clean
checkout.

Related Issues

Fixes #20761

How to Validate

Option 1 — via settings.json (new behavior):

// Add to ~/.gemini/settings.json
{
  "vertexLocation": "global"
}

Then run with a preview model:

export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT=your-project-id
gemini -m gemini-3.1-pro-preview

Expected: Request succeeds instead of returning a 404.

Option 2 — env var (existing behavior, should still work):

export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT=your-project-id
gemini -m gemini-3.1-pro-preview

Option 3 — verify priority (settings wins over env var):
Set GOOGLE_CLOUD_LOCATION=us-central1 in env and "vertexLocation": "global"
in settings. The request should go to global.

Run the tests:

npx vitest run packages/core/src/core/contentGenerator.test.ts

All 27 tests should pass including the new one:
should prefer vertexLocation from config over GOOGLE_CLOUD_LOCATION env var

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any) — no breaking changes, fully backwards compatible
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
    • Windows
      • npm run
    • Linux
      • npm run
      • npx

Famous077 and others added 25 commits March 1, 2026 16:28
@Famous077 Famous077 requested review from a team as code owners April 14, 2026 07:05
@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 introduces a persistent configuration option for Vertex AI region overrides, improving usability for users accessing experimental models. Additionally, it significantly enhances the security of the shell tool by implementing robust detection for command injection vulnerabilities, alongside necessary maintenance fixes for test suites.

Highlights

  • Vertex AI Configuration: Added a vertexLocation setting to settings.json to allow users to override the default Vertex AI region, resolving 404 errors when accessing preview models.
  • Security Enhancement: Implemented command injection detection for shell commands to block dangerous command substitution syntax like $(), backticks, and process substitution.
  • Bug Fixes: Resolved 15 TypeScript errors in shell.test.ts related to incorrect invocation.execute() arguments and updated UI snapshot tests.
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.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 14, 2026

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@Famous077
Copy link
Copy Markdown
Contributor Author

/gemini-review

@gemini-cli gemini-cli Bot added the area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt label Apr 17, 2026
@DavidAPierce
Copy link
Copy Markdown
Contributor

Howdy @Famous077 , it looks to me like this PR has some of the changes from #24170 that might not belong in this change set?
Particularly these three files:

  • packages/core/src/tools/shell.test.ts
  • packages/core/src/tools/shell.ts
  • packages/core/src/utils/shell-utils.ts

These should probably be reverted if they're not the main focus of this PR, and are being addressed in another one. Addressing that should appease some of the automatic reviewer's comments. Once the CLI comments are addressed, it also makes it easier to review manually if the comment threads have a response and/or resolution. I'm not sure if you have access to the same style "resolve conversation" button on the reply thread for comments & suggestions as maintainers do:
image
But if you do, don't hesitate to reply to the threads directly when they've been addressed and resolving the conversation by pressing the resolve conversation button if you feel like the comment has been addressed. If a reviewer feels that the resolution was insufficient, they can always re-open the thread and request additional changes. Being able to see that these comments have been read and addressed right away saves us the time from reading through commit names and diffs to deduce what if any of the comments have been addressed.

For this example, after reverting changes to files unneeded for this PR, responding to the CLI's comment about command substitution with something along the lines of "Command substitution is being handled in #24170 as a separate feature. I've reverted the changes related to it in [filenames]. Marking this thread as resolved." Would be a perfect way to close out the comment so that anyone at a glance has immediate context.

I'll proceed with a more in-depth review of the PR itself, but wanted to give actionable feedback for this or other PRs.

Thanks for your patience and contributions!

@Famous077
Copy link
Copy Markdown
Contributor Author

Hi @DavidAPierce , I have reverted all those files which you suggested me. Right now, all the tests are green. Before any extra changes, I want your suggestions. Can you review and let me know what are the changes I have to do more.

@DavidAPierce
Copy link
Copy Markdown
Contributor

Howdy again, thanks for your patience.

The work in contentGenerator.ts and config.ts LGTM.

The diff view is reporting around 300+ lines of delta in the shell related files and the seemingly unrelated changes in ExitPlanModeDialog.test.tsx.snap. I don't think these changes are needed for the fixing of #20761 which this PR is addressing.

My recommendation from here would be to completely revert the changes to:

  • packages/cli/src/ui/components/snapshots/ExitPlanModeDialog.test.tsx.snap
  • packages/core/src/tools/shell.test.ts
  • packages/core/src/tools/shell.ts
  • packages/core/src/utils/shell-utils.ts

So that the diff only shows changes to files absolutely needed for the resolution of the attached issue.

It looks like the initial changes to the shell files were made to fix some failing typescript checks, so if those are still failing after these files are reverted, then those failures can be looked into further. At the moment, I suspect they're a bit out of sorts from repeated merging and pulling.

@Famous077
Copy link
Copy Markdown
Contributor Author

Hi @DavidAPierce . Thank you for time. As per your suggestions, I have reverted all those files and some remaining build errors are pre-existing on main and unrelated to this PR. please let me know if I need to update or change anything.

@DavidAPierce
Copy link
Copy Markdown
Contributor

The diff view for this PR on github still shows 500+ line changes for:

  • packages/core/src/tools/shell.test.ts
  • packages/core/src/tools/shell.ts
  • packages/core/src/utils/shell-utils.ts

I would recommend rebasing from main for these files so that the total files changed for this PR goes from 7 -> 4 for the main focus of this PR.

I suspect that the tests and errors for the three shell files will start functioning once they're synced to what's at head in origin/main, but if they are failing because of other changes in this PR, they can be re-evalued with higher scrutiny from a position where they're what's already merged rather than having to parse the 500+ line diffs.

@Famous077 Famous077 force-pushed the feat/vertex-ai-location-override branch from d77b21f to c9fd1a8 Compare May 2, 2026 21:43
@Famous077 Famous077 marked this pull request as draft May 2, 2026 21:47
@Famous077
Copy link
Copy Markdown
Contributor Author

Hi @DavidAPierce , Can you review whenever you get time. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add Vertex AI region override to support preview models

2 participants