From 6318f91f86f08637e0e74cc4b7c2e752bfc4612d Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:41:04 +0000 Subject: [PATCH 1/2] fix(mcp): Accept null content-type and mimetype in EventAttachmentSchema --- .../mcp-core/src/api-client/schema.test.ts | 21 +++++++++++++++++++ packages/mcp-core/src/api-client/schema.ts | 7 +++++-- .../src/tools/catalog/get-event-attachment.ts | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/mcp-core/src/api-client/schema.test.ts b/packages/mcp-core/src/api-client/schema.test.ts index b95b7d6223..34eee08f07 100644 --- a/packages/mcp-core/src/api-client/schema.test.ts +++ b/packages/mcp-core/src/api-client/schema.test.ts @@ -12,6 +12,7 @@ import { AutofixRunSchema, AutofixRunStateSchema, ClientKeySchema, + EventAttachmentListSchema, EventSchema, FlamegraphSchema, IssueSchema, @@ -1159,3 +1160,23 @@ describe("event packages", () => { expect(event.packages).toEqual(packages); }); }); + +describe("EventAttachmentListSchema", () => { + it("accepts attachments stored without a content type", () => { + const [attachment] = EventAttachmentListSchema.parse([ + { + id: "123", + event_id: "c2bcb3b9321c4cccb39079c8202dd082", + type: "event.attachment", + name: "log.txt", + mimetype: null, + dateCreated: "2026-11-19T10:20:13.000000Z", + size: 42, + headers: { "Content-Type": null }, + sha1: null, + }, + ]); + expect(attachment?.mimetype).toBeNull(); + expect(attachment?.headers).toEqual({ "Content-Type": null }); + }); +}); diff --git a/packages/mcp-core/src/api-client/schema.ts b/packages/mcp-core/src/api-client/schema.ts index 3b11b002a1..680e86af02 100644 --- a/packages/mcp-core/src/api-client/schema.ts +++ b/packages/mcp-core/src/api-client/schema.ts @@ -1578,11 +1578,14 @@ export const EventAttachmentSchema = z.object({ name: z.string(), type: z.string(), size: z.number(), - mimetype: z.string(), + // Sentry serializes `content_type` here, which may be null for attachments + // stored without one (e.g. some self-hosted instances). + mimetype: z.string().nullable(), dateCreated: z.string().datetime(), // Objectstore-backed attachments do not store a usable SHA1 (checksum is // unavailable), so we neither require nor surface it from this endpoint. - headers: z.record(z.string(), z.string()).optional(), + // Legacy field: `{ "Content-Type": mimetype }`, so values may be null too. + headers: z.record(z.string(), z.string().nullable()).optional(), }); export const EventAttachmentListSchema = z.array(EventAttachmentSchema); diff --git a/packages/mcp-core/src/tools/catalog/get-event-attachment.ts b/packages/mcp-core/src/tools/catalog/get-event-attachment.ts index 44591e0df7..a56f2f55e5 100644 --- a/packages/mcp-core/src/tools/catalog/get-event-attachment.ts +++ b/packages/mcp-core/src/tools/catalog/get-event-attachment.ts @@ -227,7 +227,7 @@ export default defineTool({ output += `**Name:** ${attachment.name}\n`; output += `**Type:** ${attachment.type}\n`; output += `**Size:** ${attachment.size} bytes\n`; - output += `**MIME Type:** ${attachment.mimetype}\n`; + output += `**MIME Type:** ${attachment.mimetype ?? "unknown"}\n`; output += `**Created:** ${attachment.dateCreated}\n\n`; output += "To download this attachment with the attachmentId provided:\n"; output += `${formatToolCallInstruction({ From 8bb069634a3e181b9c10b137867bc65a8f584672 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:10:26 +0000 Subject: [PATCH 2/2] fix(mcp): Cover the observed attachment shape and drop the self-hosted claim The reported failure (CLI-4WG, sentry.io) had a string mimetype and a null headers Content-Type, so add that case to the regression test and describe both fields by Sentry's declared serializer types instead of attributing nulls to self-hosted installs. --- .../mcp-core/src/api-client/schema.test.ts | 18 ++++++++++++++++++ packages/mcp-core/src/api-client/schema.ts | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/mcp-core/src/api-client/schema.test.ts b/packages/mcp-core/src/api-client/schema.test.ts index 34eee08f07..b9c67822da 100644 --- a/packages/mcp-core/src/api-client/schema.test.ts +++ b/packages/mcp-core/src/api-client/schema.test.ts @@ -1179,4 +1179,22 @@ describe("EventAttachmentListSchema", () => { expect(attachment?.mimetype).toBeNull(); expect(attachment?.headers).toEqual({ "Content-Type": null }); }); + + it("accepts a null Content-Type header when mimetype is set", () => { + const [attachment] = EventAttachmentListSchema.parse([ + { + id: "124", + event_id: "c2bcb3b9321c4cccb39079c8202dd082", + type: "event.attachment", + name: "screenshot.png", + mimetype: "image/png", + dateCreated: "2026-11-19T10:20:13.000000Z", + size: 42, + headers: { "Content-Type": null }, + sha1: null, + }, + ]); + expect(attachment?.mimetype).toBe("image/png"); + expect(attachment?.headers).toEqual({ "Content-Type": null }); + }); }); diff --git a/packages/mcp-core/src/api-client/schema.ts b/packages/mcp-core/src/api-client/schema.ts index 680e86af02..b1de692084 100644 --- a/packages/mcp-core/src/api-client/schema.ts +++ b/packages/mcp-core/src/api-client/schema.ts @@ -1578,13 +1578,13 @@ export const EventAttachmentSchema = z.object({ name: z.string(), type: z.string(), size: z.number(), - // Sentry serializes `content_type` here, which may be null for attachments - // stored without one (e.g. some self-hosted instances). + // Sentry declares this as `str | None` (the attachment's `content_type`). mimetype: z.string().nullable(), dateCreated: z.string().datetime(), // Objectstore-backed attachments do not store a usable SHA1 (checksum is // unavailable), so we neither require nor surface it from this endpoint. - // Legacy field: `{ "Content-Type": mimetype }`, so values may be null too. + // Legacy `{ "Content-Type": ... }` field, declared `dict[str, str | None]`. + // Sentry has returned a null Content-Type here even when `mimetype` was set. headers: z.record(z.string(), z.string().nullable()).optional(), });