Skip to content

feat: gracefully handle nullable or unknown types#34

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
kweinmeister:main
Dec 30, 2025
Merged

feat: gracefully handle nullable or unknown types#34
copybara-service[bot] merged 1 commit into
google:mainfrom
kweinmeister:main

Conversation

@kweinmeister
Copy link
Copy Markdown
Contributor

This PR enhances the toGeminiSchema utility to handle JSON Schema patterns that can cause crashes or undefined behavior. It adds support for:

  • Nullable Fields: Automatically unwraps anyOf unions containing null (e.g., Optional[str]), resolving them to the underlying non-null type.

  • Type Inference: Automatically infers type: "object" or type: "array" when the explicit type field is missing but structural properties (like properties, $ref, or items) are present.

These changes ensure compatibility with MCP servers that generate flexible or slightly ambiguous JSON schemas.

Copy link
Copy Markdown
Collaborator

@kalenkevich kalenkevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests

@kalenkevich kalenkevich added the ready to pull Ready to pull for final review. label Dec 24, 2025
@copybara-service copybara-service Bot merged commit f37f0b0 into google:main Dec 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to pull Ready to pull for final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants