-
Notifications
You must be signed in to change notification settings - Fork 750
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: 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: macOS
- Language runtime version: 3.13.2
- Package version: 1.53.0
Steps to reproduce
from google.genai.types import JSONSchema, Schema
json_schema = JSONSchema(
any_of=[
JSONSchema(type='string'),
JSONSchema(type='null'),
],
description='xxx',
title='xxx'
)
schema = Schema.from_json_schema(json_schema=json_schema)
print(schema.description) # Expected: 'xxx' | Actual: None
print(schema.nullable) # True (correct)Actual Behavior
The description and title are lost. Only nullable=True and the type information are preserved.
Root Cause
In types.py, the unwrap logic at lines 2706-2712 replaces the entire schema with type_part but only carries over the default value:
if nullable_part and type_part:
default_value = schema.default
schema = type_part # <-- Loses description, title, and other fields
schema.nullable = True
if default_value is not None:
schema.default = default_valueSuggest Fix
if nullable_part and type_part:
default_value = schema.default
description_value = schema.description
title_value = schema.title
schema = type_part
schema.nullable = True
if default_value is not None:
schema.default = default_value
if description_value is not None:
schema.description = description_value
if title_value is not None:
schema.title = title_valueThanks!
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: 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.