Skip to content

feat(dashboards): Validate display type against dataset config#115951

Open
DominikB2014 wants to merge 6 commits into
masterfrom
dominikbuszowiecki/dain-1686-add-backend-validation-for-unsupported-widget-types-and
Open

feat(dashboards): Validate display type against dataset config#115951
DominikB2014 wants to merge 6 commits into
masterfrom
dominikbuszowiecki/dain-1686-add-backend-validation-for-unsupported-widget-types-and

Conversation

@DominikB2014
Copy link
Copy Markdown
Contributor

@DominikB2014 DominikB2014 commented May 20, 2026

Rejects widget create/update requests whose (widget_type, display_type) combination isn't allowed by the frontend Widget Builder's type selector (e.g. table on tracemetrics, table on preprod-app-size). Allowed combinations live in a new DATASET_CONFIG map keyed by widget_type.

For example, in the ui trace metrics don't support tables, so we shouldn't let them be saved as tables

Reject widget create/update requests whose (widget_type, display_type)
combination isn't allowed by the frontend Widget Builder's type selector
(e.g. table on tracemetrics, table on preprod-app-size).
@DominikB2014 DominikB2014 requested a review from a team as a code owner May 20, 2026 21:03
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 20, 2026

DAIN-1686

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 20, 2026
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py Outdated
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py Outdated
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
@DominikB2014 DominikB2014 marked this pull request as draft May 21, 2026 19:31
- Add SERVER_TREE to SPANS config to match frontend spans dataset config.
- Reset widget_type on context every to_internal_value so stale values
  don't leak between widgets when the serializer is used with many=True.
@DominikB2014 DominikB2014 marked this pull request as ready for review May 22, 2026 15:24
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
The AI Agents Overview prebuilt config omits widget_type for the traces
table widget, so create_widget defaults it to error-events. Subsequent
PUTs round-trip widget_type=error-events alongside the agents_traces_table
display type, which would otherwise fail the new dataset validation.
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 08d107b. Configure here.

DashboardWidgetTypes.RELEASE_HEALTH: {
"supported_display_types": _DEFAULT_CHART_AND_TABLE_TYPES
},
DashboardWidgetTypes.METRICS: {"supported_display_types": _DEFAULT_CHART_AND_TABLE_TYPES},
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.

Unreachable METRICS entry in DATASET_CONFIG is dead code

Low Severity

The DATASET_CONFIG entry keyed by DashboardWidgetTypes.METRICS (id=3) is unreachable dead code. In DashboardWidgetTypes.TYPES, the name "metrics" maps to RELEASE_HEALTH (id=2), not METRICS (id=3). So get_id_for_type_name("metrics") returns 2, and DATASET_CONFIG.get(3) is never hit through the validation flow. The entry for DashboardWidgetTypes.RELEASE_HEALTH on line 139 is the one that actually gets used when widgetType: "metrics" is sent.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 08d107b. Configure here.

Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
error-events is the create_widget default whenever a request omits
widget_type, so any system/legacy display type from a prebuilt config
that lacks widget_type ends up here (e.g. AGENTS_TRACES_TABLE from the
AI Agents Overview dashboard). Removing the config entry lets the
existing "no config = skip" branch handle it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant