fix(core): handle non-string model flags in resolution#26069
Conversation
Ensures that `argv.model` (or fallbacks) are coerced to strings before being passed to resolution logic. This prevents a TypeError when yargs parses multiple `--model` flags as an array or a value-less flag as a boolean. Fixes #23934
|
Size Change: +376 B (0%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
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 runtime crash occurring when the CLI receives unexpected input formats for the model flag, such as multiple flag declarations or boolean values. By introducing defensive type coercion and input validation, the system now reliably handles these cases, ensuring stability during model resolution. 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 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces defensive logic to handle multiple --model flags and non-string inputs by normalizing them to a single string, with updates in both the CLI and core packages. The review feedback highlights several areas for improvement: reverting unrelated and extensive changes to package-lock.json, unifying inconsistent normalization logic between packages (specifically regarding null handling and string trimming), and avoiding parameter reassignment in favor of cleaner array access methods.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…#26069) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…#26069) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Fixes a
TypeError: resolved.startsWith is not a functioncrash when starting the CLI with multiple--modelflags or a flag without a value (parsed as boolean).Details
packages/cli/src/config/config.tsto ensureargv.modelis always a string.packages/core/src/config/models.ts'sresolveModelfunction to handle non-string inputs at runtime.packages/coreandpackages/clito verify handling of arrays, booleans, and nulls in model resolution.Related Issues
Fixes #23934
How to Validate
gemini --model foo --model bar- should not crash and pick 'bar'.gemini --model- should not crash and treat it as string "true" (or whatever yargs produces).npm test -w @google/gemini-cli -w @google/gemini-cli-core.Pre-Merge Checklist