Skip to content

fix(cli): Fix a regression where Gateway authentication is rejected with Invalid auth method selected. when GOOGLE_GEMINI_BASE_URL is configured.#27558

Open
shaurya-cd wants to merge 2 commits into
google-gemini:mainfrom
shaurya-cd:fix/gateway-auth-validation
Open

fix(cli): Fix a regression where Gateway authentication is rejected with Invalid auth method selected. when GOOGLE_GEMINI_BASE_URL is configured.#27558
shaurya-cd wants to merge 2 commits into
google-gemini:mainfrom
shaurya-cd:fix/gateway-auth-validation

Conversation

@shaurya-cd
Copy link
Copy Markdown

Summary

Fix a regression where Gateway authentication is rejected with Invalid auth method selected. when GOOGLE_GEMINI_BASE_URL is configured.

getAuthTypeFromEnv() returns AuthType.GATEWAY when GOOGLE_GEMINI_BASE_URL is set, but validateAuthMethod() did not handle AuthType.GATEWAY, causing validation to fail before requests were sent.

Details

Adds validation support for AuthType.GATEWAY in validateAuthMethod().

Gateway authentication now:

  • succeeds when GOOGLE_GEMINI_BASE_URL is configured
  • returns a clear validation error when GOOGLE_GEMINI_BASE_URL is missing

Also adds regression tests covering successful and failing Gateway validation scenarios.

Related Issues

Fixes #27550

How to Validate

  1. Run the auth validation tests:
npx vitest packages/cli/src/config/auth.test.ts

Expected result:

10 passed
  1. Run the non-interactive auth tests:
npx vitest packages/cli/src/validateNonInterActiveAuth.test.ts

Expected result:

17 passed
  1. Build the project:
npm run build

Expected result:

Build is up-to-date.
Successfully copied files.
  1. Reproduce the original issue:
GOOGLE_API_KEY=proxy-token
GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8080
GOOGLE_GENAI_USE_VERTEXAI=false

Run:

gemini --prompt "Hello world" --yolo

Before this change:

Invalid auth method selected.

After this change:

Authentication validation succeeds and execution proceeds to the network layer (e.g. fetch failed if no proxy is listening on the configured endpoint).

Pre-Merge Checklist

  • Updated relevant documentation and README (not needed)

  • Added/updated tests

  • Noted breaking changes (none)

  • Validated on required platforms/methods:

    • MacOS

      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows

      • npm run
      • npx
      • Docker
    • Linux

      • npm run
      • npx
      • Docker

@shaurya-cd shaurya-cd requested a review from a team as a code owner May 29, 2026 09:10
@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 addresses a regression in the CLI's authentication flow where users were incorrectly receiving an 'Invalid auth method selected' error when attempting to use Gateway authentication. By explicitly adding validation support for the Gateway auth type and ensuring the required base URL environment variable is present, the fix restores expected functionality for Gemini integrations.

Highlights

  • Gateway Authentication Fix: Updated the authentication validation logic to correctly recognize and support AuthType.GATEWAY, resolving a regression that blocked requests when GOOGLE_GEMINI_BASE_URL was configured.
  • Validation Logic: Added a mandatory check for the GOOGLE_GEMINI_BASE_URL environment variable when using Gateway authentication to ensure proper configuration.
  • Regression Testing: Introduced new test cases in the authentication suite to verify both successful Gateway authentication and error handling for missing configuration.
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 the 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 counterproductive. 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.

Copy link
Copy Markdown
Contributor

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

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 introduces validation logic and tests for the GATEWAY authentication method, ensuring that the GOOGLE_GEMINI_BASE_URL environment variable is configured. The feedback notes that, according to the repository style guide, an empty string should be used instead of undefined to unset environment variables in tests.

Comment thread packages/cli/src/config/auth.test.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/security Issues related to security labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/security Issues related to security priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: GOOGLE_API_KEY + GOOGLE_GEMINI_BASE_URL rejected with "Invalid auth method selected" in 0.44.x (worked in 0.43.0)

1 participant