Skip to content

fix(mcp-core): Handle missing thread_metadata in TransactionProfileSchema - #1221

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/mcp-thread-metadata-validation
Open

fix(mcp-core): Handle missing thread_metadata in TransactionProfileSchema#1221
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/mcp-thread-metadata-validation

Conversation

@sentry

@sentry sentry Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a ZodError occurring when SentryApiService.getTransactionProfile(index) attempts to validate Sentry V1 profiling API responses. The TransactionProfileSchema in packages/mcp-core/src/api-client/schema.ts expected profile.thread_metadata to always be a record, but the V1 API can sometimes omit this field or send it as null.

The fix involves updating TransactionProfileSchema to use z.preprocess((value) => value ?? {}, ProfileThreadMetadataSchema) for the thread_metadata field. This ensures that if thread_metadata is missing or null, it defaults to an empty object {}, preventing validation failures. This approach mirrors the existing handling for the same field in ProfileChunkSchema within the same file.

Fixes MCP-SERVER-FSD

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@sentry
sentry Bot marked this pull request as ready for review August 1, 2026 22:43
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.

0 participants