fix(cli): validate --model argument at startup#21393
fix(cli): validate --model argument at startup#21393Adib234 merged 6 commits intogoogle-gemini:mainfrom
Conversation
|
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 significantly enhances the command-line interface's robustness and user experience by introducing early validation for the --model argument. Instead of allowing the CLI to start with an invalid model and fail later, it now proactively checks the model name at startup. This change provides immediate, actionable feedback to users, guiding them towards correct usage and preventing confusion caused by delayed errors. Highlights
Changelog
Activity
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 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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds startup validation for the --model argument, which is a great improvement for user experience. My feedback focuses on a small refactoring opportunity in packages/core/src/config/models.ts to reduce code duplication and improve maintainability by defining the list of model aliases in a single place.
|
@google-cla please recheck |
|
@gemini-code-assist Thanks for the suggestion! I've refactored the code to use a shared VALID_ALIASES constant and removed the duplicated alias list. |
|
That's great to hear, JaisalJain! Centralizing the |
|
This looks good! Can we add tests please |
Thanks for reviewing! I'll add tests for the validation behavior and update the PR shortly. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of validating the --model argument at startup by introducing early validation. The implementation is clean, and the new error messages are user-friendly, listing all valid models and aliases. The addition of comprehensive unit tests for the new validation logic is also a great inclusion. I've identified one area for improvement to make the code more robust for the future.
|
@Adib234 I've added the tests. Could you please take another look? |
Head branch was pushed to by a user without write access
531662c to
a04f5d2
Compare
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request effectively adds startup validation for the --model argument, which is a great improvement for user experience. However, the PR includes an accidentally added file (treamq) and some problematic test snapshot updates that should be removed. Additionally, there's a small bug in the new getValidModelsAndAliases function that results in duplicate model names being listed in the error message. I've left comments with suggestions for these issues.
packages/cli/src/ui/components/__snapshots__/AskUserDialog.test.tsx.snap
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…idModelsAndAliases dedup
|
@gemini-code-assist review |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Validate the
--modelCLI argument during startup to prevent invalid model names from being accepted.Previously the CLI would start normally even when an invalid model was provided (e.g.
gemini --model gemini-4-pro). The error would only appear later when sending a request, which could confuse users.This change validates the model name early and exits with a clear error message if the model is invalid.
Details
The validation checks the provided
--modelargument against theVALID_GEMINI_MODELSlist and known aliases.If the model name is invalid, the CLI exits early and prints a list of valid models and aliases to guide the user.
Related Issues
Fixes #21391
How to Validate
Expected result:
Invalid model: "gemini-4-pro"
Pre-Merge Checklist