Skip to content

fix(mcp): Handle legacy speedscope transaction profiles in get_profile_details - #1848

Open
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/mcp-legacy-speedscope-profile
Open

sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/mcp-legacy-speedscope-profile

Conversation

@sentry

@sentry sentry Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

When fetching transaction profiles via SentryApiService.getTransactionProfile, Sentry's backend proxies the profiling service (vroom) with format=sample. However, legacy profiles (such as Android and React Native on Android) do not support the sample format (LegacyProfile.IsSampleFormat() === false), so vroom responds with speedscope-formatted JSON containing profiles, shared, and camelCase metadata instead of a top-level profile object.

TransactionProfileSchema.parse was previously failing with ZodError: Failed to validate keys: profile because profile was expected as a required object.

Changes:

  • Add LegacySpeedscopeProfileSchema and isSpeedscopeProfilePayload in @sentry/mcp-core api-client to safely parse speedscope responses returned by the profiling service.
  • Update SentryApiService.getTransactionProfile to return TransactionProfile | LegacySpeedscopeProfile.
  • Keep TransactionProfileSchema strict with profile required so genuinely malformed sample profiles still fail validation and record exceptions.
  • Add formatLegacyProfileSummary in formatter.ts and dispatch to it from get-profile-details tool handler, returning a helpful metadata summary with links to Sentry UI and get_profile guidance instead of crashing.
  • Add unit tests covering speedscope legacy profile parsing and tool handling.

Fixes MCP-SERVER-GJ6

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Nov 3, 2026 5:12pm UTC

Request Review

@sentry
sentry Bot deployed to Actions November 3, 2026 10:46 Active
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 3, 2026
Resolve the client.ts conflict with #1841, which moved
getTransactionProfile to the shared toolkit-core endpoint. Pass a
TransactionProfileResponseSchema that validates speedscope bodies with
LegacySpeedscopeProfileSchema and every other body with the strict
TransactionProfileSchema. Add a test that a sample-format body without
profile data is still rejected.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the premise against both services. ProjectProfilingProfileEndpoint in getsentry/sentry always proxies to vroom with format=sample. In vroom, cmd/vroom/profile.go returns the sample body only when p.IsSampleFormat() is true, and LegacyProfile.IsSampleFormat() always returns false. Legacy profiles therefore come back as speedscope.Output (profiles, shared, camelCase metadata) with no profile key. That matches MCP-SERVER-GJ6: getTransactionProfile failed on profile with "expected object, received undefined". The schema fields also match vroom's Output/ProfileView JSON tags.

The branch conflicted with #1841, which moved getTransactionProfile to the shared toolkit-core endpoint, so I merged main in e501d72. The client now passes the shared endpoint a TransactionProfileResponseSchema. It checks speedscope bodies against LegacySpeedscopeProfileSchema and every other body against the strict TransactionProfileSchema, and isSpeedscopeProfilePayload is no longer exported. I also added a test showing that a sample-format body with no profile data still gets rejected with a profile: issue. The PR description says this, but no test covered it.

Results: all 1974 mcp-core tests pass, and so do mcp-core tsc, oxlint, and oxfmt. If I force the speedscope check off, the legacy-profile test fails.

This branch was successfully deployed

2 active deployments
Preview — e501d72f Deployed Nov 3, 2026 by vercel[bot]
Actions — e501d72f Deployed Nov 3, 2026 by sentry-junior[bot] via eval #1520
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.

0 participants