Skip to content

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

Closed

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

  1. added a commit that references this issue on Feb 11, 2026
    069b949
  2. R44VC0RP commented on Feb 11, 2026

    @R44VC0RP
    Collaborator

    Confirmed — good catch. PR #11888 fixed the case where type is explicitly non-object, but missed when type is undefined.

    Your proposed fix is correct. Per JSON Schema spec, a schema with properties/required but no explicit type should be treated as an implicit object. Adding type: "object" in that case fixes the issue.

    The relevant code is in packages/opencode/src/provider/transform.ts:796:

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

    Should add before this:

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

    Feel free to open a PR with tests.

  3. github-actions commented on Apr 13, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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