Skip to content

fix(dashboards): Reject new widgets with deprecated display types#113294

Merged
DominikB2014 merged 2 commits into
masterfrom
dominikbuszowiecki/dain-1548-prevent-saving-widgets-with-deprecated-display-types
Apr 17, 2026
Merged

fix(dashboards): Reject new widgets with deprecated display types#113294
DominikB2014 merged 2 commits into
masterfrom
dominikbuszowiecki/dain-1548-prevent-saving-widgets-with-deprecated-display-types

Conversation

@DominikB2014

Copy link
Copy Markdown
Contributor

The widget builder dropdown and widget library no longer expose stacked_area, and top_n is converted to area at every UI entry point (getTopNConvertedDefaultWidgets, deserializeDisplayType, the typeSelector dropdown). The backend still accepts both via the dashboards POST and PUT endpoints, so an API-direct client can persist widgets the UI cannot subsequently render or edit.

This PR rejects new widgets (no id) whose display_type is in the new DashboardWidgetDisplayTypes.DEPRECATED_TYPES set. The check is gated on not data.get("id") so existing widgets persisted before this change remain editable through the dashboard PUT endpoint.

Today the deprecated set is {STACKED_AREA_CHART, TOP_N}. Other backend-only types not surfaced by the frontend builder (WHEEL, RAGE_AND_DEAD_CLICKS, SERVER_TREE, AGENTS_TRACES_TABLE) are excluded because they're still emitted by the prebuilt widget library configs.

Refs DAIN-1548

The widget builder dropdown and widget library no longer expose
stacked_area, and TOP_N is converted to AREA at every UI entry point
(getTopNConvertedDefaultWidgets, deserializeDisplayType, typeSelector).
The backend, however, still accepts both via the dashboards POST and
PUT endpoints, so an API-direct client can persist widgets the UI
cannot subsequently render or edit.

Reject new widgets (no id) whose display_type is in the new
DashboardWidgetDisplayTypes.DEPRECATED_TYPES set. Existing widgets
remain editable so dashboards persisted before this change continue to
work.

Refs DAIN-1548
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code

linear-code Bot commented Apr 17, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 17, 2026
@DominikB2014
DominikB2014 marked this pull request as ready for review April 17, 2026 14:40
@DominikB2014
DominikB2014 requested review from a team as code owners April 17, 2026 14:40

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

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 8f8a32a. Configure here.

Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
@github-actions

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on 4c7f749 in this run:

tests/sentry/dashboards/endpoints/test_organization_dashboards.py::OrganizationDashboardsTest::test_post_with_deprecated_display_type_rejectedlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/dashboards/endpoints/test_organization_dashboards.py:2522: in test_post_with_deprecated_display_type_rejected
    assert (
E   KeyError: 'displayType'

CamelSnakeSerializer runs snake_to_camel_case on all error keys; passing
"displayType" lowercases it to "displaytype" because the converter only
splits on underscores. Use "display_type" so the response surfaces
"displayType" as intended.
Comment thread src/sentry/api/serializers/rest_framework/dashboard.py
@DominikB2014
DominikB2014 merged commit c8c58b7 into master Apr 17, 2026
59 checks passed
@DominikB2014
DominikB2014 deleted the dominikbuszowiecki/dain-1548-prevent-saving-widgets-with-deprecated-display-types branch April 17, 2026 15:24
@github-actions github-actions Bot locked and limited conversation to collaborators May 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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