Skip to content

fix: strip contentEncoding and contentMediaType from Gemini schemas - #15593

Closed
Br1an67 wants to merge 1 commit into
anomalyco:devfrom
Br1an67:fix/issue-15408-gemini-sanitizer
Closed

Br1an67 wants to merge 1 commit into
anomalyco:devfrom
Br1an67:fix/issue-15408-gemini-sanitizer

Conversation

@Br1an67

@Br1an67 Br1an67 commented Mar 1, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #15408

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The Gemini function calling API rejects schemas containing contentEncoding and contentMediaType — valid JSON Schema keywords that Gemini does not support. The existing sanitizeGemini function (introduced in #3140) strips properties/required from non-object types but missed these two keywords.

MCP servers like chrome-devtools-mcp use contentEncoding: "base64" in tool schemas (e.g. take_screenshot, upload_file), causing 400 errors when used with Gemini models.

The fix adds two delete calls to the existing sanitizer to strip contentEncoding and contentMediaType from all schema nodes before sending to Gemini.

How did you verify your code works?

Added two test cases in transform.test.ts covering direct and nested array scenarios. All 105 existing tests continue to pass.

Screenshots / recordings

N/A — server-side schema change, no UI impact.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The Gemini function calling API rejects schemas containing contentEncoding
and contentMediaType keywords. The existing sanitizer strips properties/required
from non-object types but missed these JSON Schema keywords.

MCP servers like chrome-devtools-mcp use contentEncoding: "base64" in tool
schemas, causing 400 errors when used with Gemini models.
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini schema sanitizer doesn't strip contentEncoding from MCP tool schemas

1 participant