Skip to content

bug: Nullable type arrays in tool schemas cause 400 error on Antigravity/Droid Factory #206

@stondy0103

Description

@stondy0103

Bug Description

When using Antigravity (Droid Factory) with Gemini models via the OpenAI Responses API, requests fail with:

400 Invalid value at 'request.tools[0].function_declarations[19].parameters.properties[3].value.type'
(type.googleapis.com/google.cloud.aiplatform.master.Type), "["STRING","NULL"]"

This happens when tool schemas include nullable types like "type": ["string", "null"] (which Claude Code and other OpenAI-compatible tools commonly send).

Root Cause

In internal/translator/gemini/openai/responses/gemini_openai-responses_request.go, lines 333-348:

if propType := value.Get("type"); propType.Exists() {
    upperType := strings.ToUpper(propType.String())
    cleaned, _ = sjson.Set(cleaned, "properties."+key.String()+".type", upperType)
}

When type is a JSON array ["string", "null"]:

  1. gjson.Result.String() returns raw text ["string","null"]
  2. strings.ToUpper()["STRING","NULL"]
  3. sjson.Set() stores it as a JSON string "[\"STRING\",\"NULL\"]" — not a JSON array
  4. Downstream flattenTypeArrays() skips it because IsArray() returns false on a string
  5. Gemini API rejects the invalid type value

Additionally, this code only iterates top-level properties — nested schemas with type arrays are not processed at all.

Suggested Fix

Remove the type uppercasing block (lines 333-348) and pass the raw schema directly:

if params := tool.Get("parameters"); params.Exists() {
    funcDecl, _ = sjson.SetRaw(funcDecl, "parametersJsonSchema", params.Raw)
}

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 logic was redundant and incomplete (top-level only)
  • No impact on other models or executors

Verified

Built and deployed the fix locally. Tested with Droid Factory (Antigravity) Gemini models — the error no longer occurs.

Fix PR

#205

Environment

  • Client: Claude Code (OpenAI Responses API format)
  • Provider: Antigravity / Droid Factory
  • Models: Gemini models via Antigravity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions