Skip to content

fix(dashboards): Add backend validation for widget layout dimensions#109826

Merged
gggritso merged 1 commit intomasterfrom
georgegritsouk/dain-1266-add-backend-api-validation-for-widget-layout-dimensions
Mar 4, 2026
Merged

fix(dashboards): Add backend validation for widget layout dimensions#109826
gggritso merged 1 commit intomasterfrom
georgegritsouk/dain-1266-add-backend-api-validation-for-widget-layout-dimensions

Conversation

@gggritso
Copy link
Member

@gggritso gggritso commented Mar 3, 2026

Replace the custom LayoutField with a LayoutSerializer using DRF's built-in IntegerField validators to reject invalid widget dimensions at the API level.

Widgets created via external tools (e.g. LLMs) can have invalid dimensions like w: 12 where the grid maximum is 6. This change prevents such layouts from being persisted. The LayoutSerializer also lets drf-spectacular auto-generate accurate OpenAPI documentation with field types and constraints, removing the need for manual @extend_schema_field annotations.

Frontend clamping counterpart: #109825

Refs DAIN-1266

@linear
Copy link

linear bot commented Mar 3, 2026

Replace the custom LayoutField with a LayoutSerializer that uses DRF's
built-in IntegerField validators (min_value/max_value) to reject
invalid widget dimensions at the API level.

This prevents widgets with out-of-bounds layouts from being persisted
via the API. The LayoutSerializer also lets drf-spectacular
auto-generate accurate OpenAPI documentation with field types and
constraints, removing the need for manual @extend_schema_field
annotations.

Refs DAIN-1266
Co-Authored-By: Claude <noreply@anthropic.com>
@gggritso gggritso force-pushed the georgegritsouk/dain-1266-add-backend-api-validation-for-widget-layout-dimensions branch from 1553218 to 5baf0cf Compare March 3, 2026 20:14
@gggritso gggritso marked this pull request as ready for review March 3, 2026 21:06
@gggritso gggritso requested a review from a team as a code owner March 3, 2026 21:06
Copy link
Member

@nikkikapadia nikkikapadia left a comment

Choose a reason for hiding this comment

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

lgtm!

@gggritso gggritso merged commit 45b07af into master Mar 4, 2026
75 of 76 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-1266-add-backend-api-validation-for-widget-layout-dimensions branch March 4, 2026 19:23
gggritso added a commit that referenced this pull request Mar 4, 2026
#109825)

Add frontend clamping for widget layout dimensions that exceed the
6-column grid bounds.

Widgets created via external tools (e.g. LLMs) can have dimensions like
`w: 12` where the maximum is `6`. This causes an infinite re-render loop
in react-grid-layout when entering edit mode, crashing the browser. The
new `clampWidgetLayout()` function normalizes dimensions before they
reach the grid library, and logs invalid layouts to Sentry for
observability.

Backend validation counterpart:
#109826

Refs DAIN-1265

Co-authored-by: Claude <noreply@anthropic.com>
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