fix(cli): add GATEWAY auth type to validateAuthMethod#27553
Conversation
AuthType.GATEWAY was added in b705505 (PR google-gemini#27021) for custom base URL routing, but validateAuthMethod() was not updated to accept it. This caused "Invalid auth method selected" (exit 41) when GOOGLE_GEMINI_BASE_URL was set with a non-standard API key. Fixes google-gemini#27550
|
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 addresses an issue where the CLI failed to recognize the 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 adds support for the GATEWAY authentication type in the CLI configuration. Specifically, it updates validateAuthMethod in packages/cli/src/config/auth.ts to return null (indicating a valid authentication method) when the auth method is AuthType.GATEWAY, and adds a corresponding unit test in packages/cli/src/config/auth.test.ts to verify this behavior. I have no feedback to provide.
Summary
AuthType.GATEWAYwas added in b705505 (PR #27021) to support custom base URL routing viaGOOGLE_GEMINI_BASE_URL, butvalidateAuthMethod()inpackages/cli/src/config/auth.tswas not updated to handle this new auth type.When
GOOGLE_GEMINI_BASE_URLis set (withGOOGLE_GENAI_USE_VERTEXAI=false),getAuthTypeFromEnv()correctly returnsAuthType.GATEWAY, butvalidateAuthMethod()falls through all existing handlers (LOGIN_WITH_GOOGLE,COMPUTE_ADC,USE_GEMINI,USE_VERTEX_AI) and returns"Invalid auth method selected."(exit code 41).Root cause
validateAuthMethod()handles four auth types but was missingGATEWAY:Fix
Added
AuthType.GATEWAYhandler that returnsnull(valid, no validation needed). Gateway auth delegates authentication to the gateway itself — API keys are optional, handled downstream increateContentGeneratorConfigwhich falls back toGEMINI_API_KEYor empty string.Changes
packages/cli/src/config/auth.ts— addGATEWAYcase tovalidateAuthMethod()packages/cli/src/config/auth.test.ts— add test case forGATEWAYauth typeTest plan
npx vitest run packages/cli/src/config/auth.test.ts— 9/9 tests pass (including new GATEWAY test)npx vitest run packages/core/src/core/contentGenerator.test.ts— 47/47 tests pass (no regressions)git diffcontains only the two intended file changesFixes #27550