fix(cli): Fix a regression where Gateway authentication is rejected with Invalid auth method selected. when GOOGLE_GEMINI_BASE_URL is configured.#27558
Conversation
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 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
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 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 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
|
There was a problem hiding this comment.
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.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Fix a regression where Gateway authentication is rejected with
Invalid auth method selected.whenGOOGLE_GEMINI_BASE_URLis configured.getAuthTypeFromEnv()returnsAuthType.GATEWAYwhenGOOGLE_GEMINI_BASE_URLis set, butvalidateAuthMethod()did not handleAuthType.GATEWAY, causing validation to fail before requests were sent.Details
Adds validation support for
AuthType.GATEWAYinvalidateAuthMethod().Gateway authentication now:
GOOGLE_GEMINI_BASE_URLis configuredGOOGLE_GEMINI_BASE_URLis missingAlso adds regression tests covering successful and failing Gateway validation scenarios.
Related Issues
Fixes #27550
How to Validate
Expected result:
Expected result:
Expected result:
Run:
gemini --prompt "Hello world" --yoloBefore this change:
After this change:
Authentication validation succeeds and execution proceeds to the network layer (e.g.
fetch failedif 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
Windows
Linux