Repository navigation
fix(mcp): List existing attributes when search validation rejects a key - #2211
sentry-junior[bot] wants to merge 1 commit into
Conversation
Sentry's events/validate endpoint only says "Unknown attribute" for a key it can't resolve. When a caller passes explicit fields to search_logs, search_traces, or search_metrics, the handler trusts them and the final validation gate fails with no way to find the right key. On that failure, look up attributes that share the rejected key's stem (error.message -> error) in the same dataset, project, and time range, and append them to the error. A failed lookup leaves the error unchanged. Fixes MCP-SERVER-GPC (search_logs rejected error.message and error.stack; the real key was error).
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Another report of this pattern, from Evidence (log
Gap in this PR for this case: |
When a caller passes explicit
fieldstosearch_logs/search_traces/search_metrics, the handler trusts them over the embedded agent's picks. If one is wrong, the final validation gate fails with only Sentry'sUnknown attribute, so the caller has no way to find the right key.On that failure, the handler now looks up attributes that share the rejected key's stem (
error.message→error). It uses the same dataset, project, and time range, does at most 3 lookups and lists up to 10 keys each, then adds them to the error:If the lookup fails, the hint is skipped (we log a warning) and the original validation error stays unchanged.
Why: user feedback MCP-SERVER-GPC (opencode, 0.42.0). In span
bc2a4ee252160576(tracec3c0ff03…),search_logswas called withfields: [..., "error", "error.message", "error.stack"]. The final/events/validate/returnedUnknown attributefor both keys (sentryorganization_events_validate.py:318), and the tool answered with only that. The embedded agent had already looked these keys up viadatasetAttributes, but because explicit fields are trusted (resolveEventFields, search.ts), its picks were dropped. The retry without the two fields worked; the real key waserror.Not covered: the same feedback also said
search_issuesrewrote"organization step(s) failed"toorganization step failed. That call isn't in the sampled spans, so it isn't fixed here. It's tracked separately.Tests: regression test in
search-events.test.ts(fails without this change), plus a test that a failing lookup keeps the original error.mcp-coretsc, oxlint, oxfmt and the fullmcp-corevitest suite pass locally.via Sentry.
--
View Session [Sentry]