Repository navigation
fix(py/google-genai)!: strict nested Gemini and Veo config; google_search replaces google_search_retrieval - #6593
Merged
huangjeff5 merged 11 commits intoOct 8, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the configuration schemas for Gemini, Veo, and Lyria models to forbid undeclared configuration keys by setting extra='forbid' and marking additionalProperties as False in their JSON schemas. It also renames google_search_retrieval to google_search, explicitly declares supported fields on VeoConfig, and updates the test suite to verify that validation errors are raised on construction for unknown keys. There are no review comments, so I have no feedback to provide.
huangjeff5
force-pushed
the
fix/py-gemini-config-strict
branch
from
October 6, 2026 10:02
e6b08a0 to
970750b
Compare
huangjeff5
force-pushed
the
fix/py-gemini-config-strict
branch
from
October 6, 2026 10:12
970750b to
f184e6f
Compare
…oogle_search replaces google_search_retrieval
huangjeff5
force-pushed
the
fix/py-gemini-config-strict
branch
from
October 6, 2026 10:19
f184e6f to
bdcaa36
Compare
huangjeff5
marked this pull request as ready for review
October 6, 2026 22:14
huangjeff5
changed the base branch from
fix/py-config-unknown-key-raises-main
to
fix/py-model-config-any-model
October 7, 2026 04:56
apascal07
approved these changes
Oct 7, 2026
…Veo extra guards instances
- Each strict nested Gemini class declares exactly the fields of the
google-genai type it is sent as (SafetySetting.method, ImageConfig
output/person/prominent fields, FunctionCallingConfig
.stream_function_call_arguments, VoiceConfig.replicated_voice_config).
A test pins the field sets, so a new SDK field fails CI, not users.
- code_execution / google_search / url_context dicts validate against
the SDK tool type: a bad key raises INVALID_ARGUMENT with its dotted
path instead of FAILED 'internal error'. False attaches no tool.
- attach_config_extra takes the family's managed body fields; Veo
rejects extra={'instances': ...} and keeps the plugin's extra_body.
- Drop Veo's unreachable leftovers branch and api_key re-checks.
- Leave the unused _lyria.LyriaConfig untouched; Interactions Lyria
strictness lands in #6646.
…nfig - Rename ThinkingConfigSchema, FileSearchConfigSchema, ImageConfigSchema, VoiceConfigSchema, SpeakerVoiceConfigSchema, MultiSpeakerVoiceConfigSchema, and SpeechConfigSchema to *Config. - Retain backwards-compatibility aliases in _gemini.py. - Update tests and Dev UI schema $defs lookup.
…nto fix/py-gemini-config-strict # Conflicts: # py/packages/genkit-google-genai/tests/models/googlegenai_gemini_test.py # py/packages/genkit-google-genai/tests/veo_test.py
…nto fix/py-gemini-config-strict
…nto fix/py-gemini-config-strict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nested Gemini settings and
VeoConfigreject unknown keys before the request. Each nested setting declares exactly the fields of the google-genai type it is sent as, so an SDK field never fails the check.google_searchreplacesgoogle_search_retrieval. A Veo API key inconfigorextrapoints atcontext.secretsinstead of riding into the request body. Top-level unknown keys onGeminiConfigalready raise on #6587. Interactions Lyria strictness is in #6646.Decisions
thinking_config,safety_settings,speech_config, ...) and Veo still dropped or forwarded typos. Now every level raises with the dotted path, including tool options (google_search.exclude_domainz). Each nested class declares exactly its google-genai type's fields (SafetySetting.method,ImageConfig.output_mime_type, ...), and a test pins the sets so a new SDK field fails CI rather than users.extra=is how a field the class does not declare still reaches the API.google_searchis the tool switch: The oldgoogle_search_retrievalname pointed at a retired tool, and any non-None value attached search, soFalseturned it on. Nowgoogle_search=Trueattaches the tool, an options dict is validated againstgenai_types.GoogleSearch, andFalseorNoneattaches nothing.url_contextandcode_executionfollow the same rule. The old name, and the JS spellinggoogleSearchRetrieval, fail with an error that namesgoogle_searchrather than the generic unknown-key message.VeoConfigdeclares everyGenerateVideosConfigfield (e.g.generate_audio,number_of_videos) with camelCase aliases, pinned by a test. A key inconfigor inextrastill raises thecontext.secretserror, not "put it in extra", so a tenant key never lands in the request body.extracan't replace what Genkit builds: each family names its managed body fields. Gemini rejectscontents,tools, ...; Veo rejectsinstances. A request'sextralayers over the plugin'shttp_options.extra_bodyinstead of replacing it.Breaking changes
thinking_config,safety_settings,function_calling_config,speech_config,file_search, orimage_configraisesINVALID_ARGUMENTnaming the path; move undeclared fields toextraunder their REST name.google_search_retrievalis removed: it failsINVALID_ARGUMENTwithgoogle_search_retrieval was renamed to google_search; usegoogle_search/googleSearch.google_search,url_context,code_executiontake True or an options dict: False attaches nothing, and the options dict is validated against the SDK tool type. Before, any non-Nonegoogle_searchattached the tool, andcode_execution={}attached nothing.extra={'parameters': {...}}.extramerges at its wire path: it used to land as a literalparameters.extrafield.extra={'instances': ...}raises.additionalProperties: false.API changes
GeminiConfig.google_search:bool | genai_types.GoogleSearch | None, aliasgoogleSearch; replacesgoogle_search_retrieval.url_contextandcode_executionare typed the same way withUrlContext/ToolCodeExecution.VeoConfigdeclares SDK fields:number_of_videos,generate_audio,fps,output_gcs_uri,pubsub_topic,compression_quality,resize_mode,labels,last_frame,reference_images,mask,webhook_config, each with a camelCase alias.VeoConfig.extra:dict[str, Any] | None, merged into the request body.Cross-SDK
extramatches Go: Go uses SDK types withadditionalProperties: false. JS schemas are passthrough, so unknown keys go to the provider body.google_searchmatches JS Google AI'sgoogleSearch. JS Vertex still only knowsgoogleSearchRetrieval, so the old name fails with a targeted error naminggoogle_search.generateAudio,compressionQuality,resizeMode, andlocation.