Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/mcp-core/src/api-client/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
AutofixRunSchema,
AutofixRunStateSchema,
ClientKeySchema,
EventAttachmentListSchema,
EventSchema,
FlamegraphSchema,
IssueSchema,
Expand Down Expand Up @@ -1159,3 +1160,41 @@ 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 });
});

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 });
});
});
7 changes: 5 additions & 2 deletions packages/mcp-core/src/api-client/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1578,11 +1578,14 @@ export const EventAttachmentSchema = z.object({
name: z.string(),
type: z.string(),
size: z.number(),
mimetype: z.string(),
// 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.
headers: z.record(z.string(), z.string()).optional(),
// 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(),
});

export const EventAttachmentListSchema = z.array(EventAttachmentSchema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading