Skip to content

fix(mcp): return JSON attachments as text - #2412

Open
cast-vytautas wants to merge 1 commit into
getsentry:mainfrom
cast-vytautas:fix/json-attachments-mcp-text
Open

cast-vytautas wants to merge 1 commit into
getsentry:mainfrom
cast-vytautas:fix/json-attachments-mcp-text

Conversation

@cast-vytautas

Copy link
Copy Markdown

Summary

Return application/json and application/jsonl event attachments through the existing text-decoding path instead of wrapping them as embedded-resource blobs. The resulting text block preserves the JSON payload inside the handler's existing header and Markdown fence.

 application/json and application/jsonl
-  embedded-resource blob
+  TextDecoder
+  one text block; payload unchanged

text/plain, images, and generic application/octet-stream behavior is unchanged. This PR does not deploy the service or alter the separate gateway adapter.

Evidence

  • Before: JSON and JSONL took the non-text resource path. The observed gateway flattened the embedded resource, and clients rejected the response with invalid_union under content[0].
    After: the handler emits one text part containing the exact UTF-8 attachment payload, with no resource or image part.
  • Focused attachment suite: 11/11 passed, including JSON, JSONL, protocol-shape, and binary-preservation cases.
  • Broader mcp-core tests passed.
  • Typechecking, linting, and formatting passed.

Merge Danger

Door: Two-way. Reverting restores the previous attachment response behavior without a data migration.

Blast Radius: Only get_event_attachment responses for JSON and JSONL MIME types. Other MIME types keep their existing branches. The live service needs a separate deployment after merge.

Treat application/json and application/jsonl as text to avoid embedded-resource validation failures. Cover exact payload decoding, protocol validity, and binary preservation (LLM-4380).

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@cast-vytautas
cast-vytautas requested a review from a team as a code owner November 19, 2026 04:43
@vercel

vercel Bot commented Nov 19, 2026

Copy link
Copy Markdown

@cast-vytautas is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 19, 2026

This branch has not been deployed

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant