Skip to content

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

Merged
DominikB2014 merged 6 commits into
masterfrom
dominikbuszowiecki/dain-1686-add-backend-validation-for-unsupported-widget-types-and
May 25, 2026
Merged

feat(dashboards): Validate display type against dataset config#115951
DominikB2014 merged 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.

Adding the dataset configs also sets us up nicely for more per dataset validation

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.

Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
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.
Comment on lines +129 to +132
# ERROR_EVENTS is intentionally omitted: it's the ``create_widget`` default
# when a request omits widget_type, so any system display type a prebuilt
# config doesn't tag will land here. Without a config entry the validation
# falls through and lets the request pass.
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.

If it's not tagged, and defaults to ERROR_EVENTS, then imo we should just treat it with the error events config constraints instead of allowing the request to skip this check

Copy link
Copy Markdown
Contributor Author

@DominikB2014 DominikB2014 May 25, 2026

Choose a reason for hiding this comment

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

That's true, I can do that as a followup!
There's there's some widget types we used for prebuilt dashboards that don't have the dataset defined, such as RAGE_AND_DEAD_CLICKS which means when they save they will get error_events. It's technically not a error events widget though, so we'll have to go through these cases and see what the best path forward is, maybe we just need a widgetType for non-dataset widget and run a migration.

@DominikB2014 DominikB2014 merged commit 3a5d766 into master May 25, 2026
65 checks passed
@DominikB2014 DominikB2014 deleted the dominikbuszowiecki/dain-1686-add-backend-validation-for-unsupported-widget-types-and branch May 25, 2026 17:03
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.

2 participants