Skip to content

fix(dashboards): validate threshold JSON shape - #129621

Draft
sentry-junior[bot] wants to merge 1 commit into
josh/typing-strict-types-onlyfrom
josh/typing-stack/dashboard-thresholds-validation
Draft

sentry-junior[bot] wants to merge 1 commit into
josh/typing-strict-types-onlyfrom
josh/typing-stack/dashboard-thresholds-validation

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Stacked on #129614 (strict mypy, types only). This is #129434 rebased onto it so the fix lands after the typing PR.

Thresholds are stored in a JSONField. Validate their shape at write time:

  • thresholds must be an object
  • max_values must be an object with only max1/max2 keys, numeric values, and increasing values
  • unit must be a string or null

Change from #129434: #129434 required integer maximums. That would reject the prebuilt web-vitals dashboards (CLS uses max1: 0.1, max2: 0.25) and any decimal a user types in the widget builder, which sends Number(value). Maximums now accept int or float and still reject bool. Added test_update_widget_with_decimal_thresholds.

Tests cover non-object thresholds, non-object max_values, unknown keys, non-numeric values, non-string units, and decimal maximums.

via @joshuarli.

--

View Session [Sentry]

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
@sentry-junior
sentry-junior Bot force-pushed the josh/typing-strict-types-only branch from 9fda5d0 to 73fa505 Compare November 3, 2026 00:31
@sentry-junior
sentry-junior Bot force-pushed the josh/typing-stack/dashboard-thresholds-validation branch from 3cd4e5e to 538110b Compare November 3, 2026 00:34
@sentry-junior
sentry-junior Bot force-pushed the josh/typing-stack/dashboard-thresholds-validation branch from 538110b to 9bb509f Compare November 3, 2026 12:02

This branch has not been deployed

No deployments
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