fix(translator): fix nullable type arrays breaking Gemini/Antigravity API#1511
fix(translator): fix nullable type arrays breaking Gemini/Antigravity API#1511stondy0103 wants to merge 1 commit intorouter-for-me:mainfrom
Conversation
…o-Gemini translator The `ConvertOpenAIResponsesRequestToGemini` function had code that attempted to uppercase JSON Schema type values (e.g. "string" -> "STRING") for Gemini compatibility. This broke nullable types because when `type` is a JSON array like `["string", "null"]`: 1. `gjson.Result.String()` returns the raw JSON text `["string","null"]` 2. `strings.ToUpper()` produces `["STRING","NULL"]` 3. `sjson.Set()` stores it as a JSON **string** `"[\"STRING\",\"NULL\"]"` instead of a JSON array 4. The downstream `CleanJSONSchemaForGemini()` / `flattenTypeArrays()` cannot detect it (since `IsArray()` returns false on a string) 5. Gemini/Antigravity API rejects it with: `400 Invalid value at '...type' (Type), "["STRING","NULL"]"` This was confirmed and tested with Droid Factory (Antigravity) Gemini models where Claude Code sends tool schemas with nullable parameters. The fix removes the uppercasing logic entirely and passes the raw schema through to `parametersJsonSchema`. This is safe because: - Antigravity executor already runs `CleanJSONSchemaForGemini()` which properly handles type arrays, nullable fields, and all schema cleanup - Gemini/Vertex executors use `parametersJsonSchema` which accepts raw JSON Schema directly (no uppercasing needed) - The uppercasing code also only iterated top-level properties, missing nested schemas entirely Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @stondy0103, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a bug where nullable JSON schema type arrays were being corrupted during translation, leading to API errors. The fix is to remove the problematic logic that was incorrectly uppercasing type values. By passing the raw parameters schema and delegating the cleaning to a downstream component, the code is now more robust and simpler. The removed logic was also incomplete as it only handled top-level properties, so this change improves correctness for nested schemas as well. This is a good fix, well-explained in the pull request description.
Summary
ConvertOpenAIResponsesRequestToGeminiwhere nullable JSON Schema type arrays (e.g.["string", "null"]) were corrupted into invalid string values"[\"STRING\",\"NULL\"]", causing Gemini/Antigravity API to reject requests with400 Invalid value at '...type'CleanJSONSchemaForGemini()inantigravity_executor.goalready handles type flattening, nullable fields, and schema cleanup correctlyRoot Cause
When a tool parameter has
"type": ["string", "null"](JSON array):gjson.Result.String()returns raw text["string","null"]strings.ToUpper()→["STRING","NULL"]sjson.Set()stores as a JSON string"[\"STRING\",\"NULL\"]"(not an array)flattenTypeArrays()skips it (IsArray()== false on a string)400 Invalid value at '...type' (Type), "["STRING","NULL"]"Verified
This fix has been tested and confirmed working with Droid Factory (Antigravity) using Gemini models, where Claude Code sends tool schemas with nullable parameters (e.g.
"type": ["string", "null"]). The error no longer occurs after removing the broken uppercasing logic.Impact
CleanJSONSchemaForGemini()handles everythingparametersJsonSchemawhich accepts raw JSON SchemaTest plan
["string", "null"]are properly flattened by downstreamCleanJSONSchemaForGemini()🤖 Generated with Claude Code