Repository navigation
fix(mcp): Accept null dashboard environment filters from Sentry API - #2171
sentry[bot] wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Looks good to me. I checked the premise against the producer in getsentry/sentry. The dashboard validator declares environment as a ListField(..., allow_null=True), and update_dashboard_filters stores whatever was sent in Dashboard.filters. Then DashboardFiltersMixin.get_filters reads it back with dashboard_filters.get("environment", []), which returns None when the key is saved as null. Both the list and the details serializers return that value, so environment: null is a real API shape for both DashboardListItemSchema and DashboardSchema, not malformed data. The linked issue shows exactly this failure in listDashboards (10.environment: expected array, received null), so one dashboard breaks find_dashboards for the whole org.
The z.preprocess((value) => value ?? [], z.array(z.string())) shape matches the existing urls field in this file. Only nullish values are coerced, and non-string entries are still rejected. I merged the branch with current main (which now has no-unnecessary-condition enabled for mcp-core) and ran the checks there: mcp-core tsc and oxlint on the changed files are clean, and schema.test.ts, find-dashboards.test.ts, and get-dashboard-details.test.ts pass. The new find_dashboards regression test fails on main's schema.
|
This PR has had no activity for 3 days. It closes in 2 days unless someone pushes, comments, or adds the |
Resolve the schema.test.ts conflict with #2425 by keeping both the dashboard environment tests and the EventAttachmentListSchema tests.
There was a problem hiding this comment.
This branch conflicted with main after #2425 added EventAttachmentListSchema tests to the same spot in schema.test.ts. I merged main in 5871970 and kept both sets of tests. The fix itself didn't change.
It's still needed: DashboardListItemSchema and DashboardSchema on main still use z.array(z.string()).default([]), which rejects null. With main's schema.ts swapped in, the 3 null-environment tests fail. With this branch they pass, along with the rest of schema.test.ts, find-dashboards.test.ts and get-dashboard-details.test.ts. The mcp-core typecheck is clean.
|
The red |
BYK
left a comment
There was a problem hiding this comment.
Shouldn't we fix this on the server side over at getsentry/sentry?
The Sentry API can return
"environment": nullon saved dashboard objects when the dashboard's environment filter was saved with a null value. Previously,DashboardListItemSchemaandDashboardSchemadefinedenvironment: z.array(z.string()).default([]). Because Zod's.default()only substitutes values forundefined, an explicitnullfrom the Sentry API resulted in anApiResponseValidationError("expected array, received null"), causingfind_dashboardsandget_dashboard_detailsto fail for entire organizations containing such dashboards.Changes:
z.preprocess((value) => value ?? [], z.array(z.string()))for theenvironmentfield inDashboardListItemSchemaandDashboardSchemaso bothnullandundefinedare coerced to[].packages/mcp-core/src/api-client/schema.test.tsverifying thatnull,undefined, and string array environments parse as string arrays.packages/mcp-core/src/tools/catalog/find-dashboards.test.tsverifying that a dashboard withenvironment: nullis processed without error and returnsenvironments: [].Fixes MCP-SERVER-GNF
@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.