Skip to content

[bug] Gemini schema sanitization misses properties/required when type is undefined #13148

Description

@fwkyle

Bug Description

sanitizeGemini in transform.ts strips properties and required from non-object types, but misses the case where type is entirely undefined.

This is a follow-up edge case from #11889 / PR #11888.

Root Cause

The current check:

if (result.type && result.type !== "object") {
  delete result.properties
  delete result.required
}

When type is undefined, result.type && ... short-circuits to false, so properties/required are not removed.

Reproduction

MCP tools like Notion MCP define schemas where type is omitted but properties/required are present:

{
  "data": {
    "description": "The data required for updating a page",
    "properties": { "page_id": { "type": "string" } },
    "required": ["page_id"]
  }
}

This causes:

Bad Request: GenerateContentRequest.tools[0].function_declarations[90].parameters.properties[data].properties: only allowed for OBJECT type

Expected Behavior

Schemas with properties/required but no type should be treated as implicit objects (per JSON Schema spec) and have type: "object" added.

Proposed Fix

// Add type "object" for schemas with properties/required but missing type
if (!result.type && (result.properties || result.required)) {
  result.type = "object"
}

Environment

  • OpenCode v1.1.56
  • Notion MCP Server
  • Gemini model (google provider)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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