Skip to content

fix(mcp): Accept null dashboard environment filters from Sentry API - #2171

Open
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix-dashboard-null-environment
Open

sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix-dashboard-null-environment

Conversation

@sentry

@sentry sentry Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

The Sentry API can return "environment": null on saved dashboard objects when the dashboard's environment filter was saved with a null value. Previously, DashboardListItemSchema and DashboardSchema defined environment: z.array(z.string()).default([]). Because Zod's .default() only substitutes values for undefined, an explicit null from the Sentry API resulted in an ApiResponseValidationError ("expected array, received null"), causing find_dashboards and get_dashboard_details to fail for entire organizations containing such dashboards.

Changes:

  • Use z.preprocess((value) => value ?? [], z.array(z.string())) for the environment field in DashboardListItemSchema and DashboardSchema so both null and undefined are coerced to [].
  • Add unit tests in packages/mcp-core/src/api-client/schema.test.ts verifying that null, undefined, and string array environments parse as string arrays.
  • Add a regression test in packages/mcp-core/src/tools/catalog/find-dashboards.test.ts verifying that a dashboard with environment: null is processed without error and returns environments: [].

Fixes MCP-SERVER-GNF

@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 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
cli Ready Ready Preview Nov 30, 2026 5:07pm UTC
sentry-local Ready Ready Preview Nov 30, 2026 5:07pm UTC

Request Review

@sentry
sentry Bot deployed to Actions November 11, 2026 10:44 Active
@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 11, 2026

@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.

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.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has had no activity for 3 days. It closes in 2 days unless someone pushes, comments, or adds the WIP label.

@github-actions github-actions Bot added the Stale label Nov 22, 2026
Resolve the schema.test.ts conflict with #2425 by keeping both the
dashboard environment tests and the EventAttachmentListSchema tests.
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 30, 2026 17:06

@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.

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.

@sentry-junior

sentry-junior Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

The red test check on 5871970 isn't from this PR. It's packages/cli/test/lib/target-scope-coverage.test.ts, which now finds an unguarded lib/wizard/nuxt/templates.ts. That file came from #2525, and the same test fails on main at bd2ab8c. I'm leaving that fix out of this PR since it's unrelated. This PR needs a re-run once main is green again.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we fix this on the server side over at getsentry/sentry?

@BYK
BYK enabled auto-merge November 30, 2026 20:59

This branch was successfully deployed

3 active and 1 inactive (outdated) deployments
Preview – cli — 58719701 Deployed Nov 30, 2026 by vercel[bot]
Preview – sentry-local — 58719701 Deployed Nov 30, 2026 by vercel[bot]
Actions — 58719701 Deployed Nov 30, 2026 by sentry-junior[bot] via eval #2103
Preview — b7e9dbf7 Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant