Repository navigation
fix(mcp): Handle legacy speedscope transaction profiles in get_profile_details - #1848
sentry[bot] wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
There was a problem hiding this comment.
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.
When fetching transaction profiles via
SentryApiService.getTransactionProfile, Sentry's backend proxies the profiling service (vroom) withformat=sample. However, legacy profiles (such as Android and React Native on Android) do not support the sample format (LegacyProfile.IsSampleFormat() === false), sovroomresponds with speedscope-formatted JSON containingprofiles,shared, and camelCase metadata instead of a top-levelprofileobject.TransactionProfileSchema.parsewas previously failing withZodError: Failed to validate keys: profilebecauseprofilewas expected as a required object.Changes:
LegacySpeedscopeProfileSchemaandisSpeedscopeProfilePayloadin@sentry/mcp-coreapi-client to safely parse speedscope responses returned by the profiling service.SentryApiService.getTransactionProfileto returnTransactionProfile | LegacySpeedscopeProfile.TransactionProfileSchemastrict withprofilerequired so genuinely malformed sample profiles still fail validation and record exceptions.formatLegacyProfileSummaryinformatter.tsand dispatch to it fromget-profile-detailstool handler, returning a helpful metadata summary with links to Sentry UI andget_profileguidance instead of crashing.Fixes MCP-SERVER-GJ6
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.