-
Notifications
You must be signed in to change notification settings - Fork 602
Open
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.status:awaiting user responsestatus:staletype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: Python
- OS: Mac
- Language runtime version: 3.12
- Package version: 1.40.0
Steps to reproduce
- Define a JSON schema that uses prefixItems.
- Attempt to validate it using google.genai.types.Schema.model_validate().
import google.genai.types as types
import pydantic
JSON_SCHEMA = {
"type": "array",
"prefixItems": [
{
"type": "object",
"properties": {
"id": {"const": 42},
"original": {"type": "string", "maxLength": 750},
"thoughts": {"type": "string", "maxLength": 650},
"translation": {"type": "string", "maxLength": 1000}
}
}
],
"items": {
"type": "object",
"properties": {
"id": {"type": "integer"},
"original": {"type": "string"},
"thoughts": {"type": "string"},
"translation": {"type": "string"}
},
"required": ["id", "original", "thoughts", "translation"]
}
}
try:
schema = types.Schema.model_validate(JSON_SCHEMA)
except pydantic.ValidationError as e:
print(f"ERROR: {e}")
Outputs:
ERROR: 1 validation error for Schema
prefixItems
Extra inputs are not permitted [type=extra_forbidden, input_value=[{'type': 'object', 'prop...', 'maxLength': 1000}}}], input_type=list]
For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden
As per this press release from May, prefixItems should be supported.
Metadata
Metadata
Assignees
Labels
priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.status:awaiting user responsestatus:staletype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.