You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API schema: type occurrence evidenceData per occurrence type (starting with metric issues) #129578
In the public API schema, the serialized issue occurrence types evidenceData as dict[str, Any]. That's IssueOccurrenceResponse.evidenceData in src/sentry/issues/issue_occurrence.py. In the generated @sentry/api client (getsentry/sentry-api-schema) it becomes { [key: string]: unknown }, so API consumers get no type checking for evidence fields.
This caused a real bug in the Sentry MCP: getsentry/toolkit#1087, fixed in getsentry/toolkit#1715. The MCP read snake_case keys (data_sources, query_obj, snuba_query, time_window) from metric issue evidence. EventSerializer (src/sentry/api/serializers/models/event.py) recursively camelCases the occurrence with convert_dict_key_case(occurrence.to_dict(), snake_to_camel_case), so the API actually returns dataSources, queryObj, snubaQuery and timeWindow. The monitor's dataset, aggregate, query and interval silently disappeared, and the tests passed only because they used hand-written snake_case fixtures. A typed schema would have caught this at compile time.
Proposal
Type occurrence.evidenceData in the OpenAPI output per occurrence type, for example as a discriminated union on occurrence.type.
Start with metric issues (8001). The shape already exists as MetricIssueEvidenceData in src/sentry/incidents/grouptype.py: detectorId, value, conditions, and dataSources[].queryObj.snubaQuery.{dataset, aggregate, query, timeWindow, environment}.
Use the camelCase keys the serializer actually emits, not the snake_case dataclass fields. Otherwise the generated types repeat the same mismatch.
Activity
linear-code commentedon Nov 2, 2026
ENG-8952
feat(api): Type metric issue occurrence evidenceData in the API schema
chore(mcp): Type metric evidence against generated @sentry/api schema (…
feat(api): Type metric issue occurrence evidenceData in the API schema (