fix: strip $schema and convert array types in Gemini schema conversion#5585
fix: strip $schema and convert array types in Gemini schema conversion#5585colegottdank merged 1 commit intomainfrom
Conversation
Fixes 400 errors on Gemini requests with structured output: - Strip $schema field from JSON schemas (Gemini doesn't recognize it) - Convert array types like ["string", "null"] to type: "string" + nullable: true Addresses errors: - "Unknown name '$schema' at 'generation_config.response_schema'" - "Unknown name 'type' at '...': Proto field is not repeating, cannot start list" Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Claude finished @colegottdank's task —— View job Code Review: Gemini Schema Conversion FixesScore: 8/10 - Well-implemented fix with good test coverage, ready to merge with minor suggestions AnalysisThis PR effectively addresses the 400 errors from Gemini's API by implementing proper schema transformation. The implementation correctly handles two key issues:
Strengths✅ Comprehensive test coverage - Tests cover all transformation scenarios including edge cases Code Quality AssessmentImplementation (
Tests (
Minor Suggestions
Security & Performance✅ No security concerns - Pure transformation function with no external dependencies VerificationThe test cases demonstrate the fix addresses the exact errors mentioned:
Ready to merge - This implementation properly fixes the Gemini API compatibility issues while maintaining robust error handling and test coverage. |
Summary
Fixes 400 errors on Gemini model requests with structured output/response_format:
$schemafield from JSON schemas (Gemini doesn't recognize it)["string", "null"]totype: "string"+nullable: trueErrors fixed
Test plan
$schemastripping🤖 Generated with Claude Code