Fix Pydantic v2.11+ compatibility in BaseModel #1270
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.
Summary
Fixes Pydantic v2.11+ compatibility issue where google-genai v1.30.0 fails to import due to deprecated
populate_by_name
configuration parameter.Problem
Import fails with
pydantic_core._pydantic_core.SchemaError: Invalid Schema: model.config.populate_by_name Extra inputs are not permitted
when using Pydantic v2.11+.Root Cause
google/genai/_common.py
line 417 uses deprecatedpopulate_by_name=True
parameter. According to Pydantic documentation: "populate_by_name usage is not recommended in v2.11+ and will be deprecated in v3." The official replacement isvalidate_by_name=True
+validate_by_alias=True
.Solution
validate_by_name=True
+validate_by_alias=True
for Pydantic v2.11+populate_by_name=True
for Pydantic v1 backward compatibilityTesting
Impact
Resolves breaking change that forced users to downgrade to google-genai v1.29.0 when using modern Pydantic versions.
References