Skip to content

fix(widget-builder): Prevent crash when threshold max_values is undefined - #124855

Merged
TkDodo merged 4 commits into
masterfrom
seer/fix-widget-thresholds-crash
Sep 18, 2026
Merged

TkDodo merged 4 commits into
masterfrom
seer/fix-widget-thresholds-crash

Conversation

@sentry

@sentry sentry Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a TypeError: Cannot read properties of undefined (reading 'max1') occurring in the widget builder's thresholds step.

The root cause was identified in static/app/views/dashboards/widgetBuilder/buildSteps/thresholdsStep/thresholds.tsx. Lines 105-106 attempted to access thresholdsConfig?.max_values[ThresholdMaxKeys.MAX_1] (and MAX_2). While thresholdsConfig was optionally chained, max_values itself was not. If thresholdsConfig existed but max_values was undefined (which can happen despite the TypeScript type declaring it as required), the bracket access undefined['max1'] would throw a TypeError.

The fix involves adding optional chaining (?.) to the max_values property access, changing thresholdsConfig?.max_values[key] to thresholdsConfig?.max_values?.[key]. This ensures that if max_values is undefined, the expression short-circuits, and the ?? '' fallback correctly provides an empty string, preventing the crash.

A regression test has been added to thresholds.spec.tsx to cover the scenario where max_values is undefined, ensuring the component renders correctly without errors.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes JAVASCRIPT-3BYC

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@sentry
sentry Bot requested a review from a team as a code owner September 17, 2026 22:43
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 17, 2026
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Story previews

Preview the stories changed in this PR on the Vercel deployment:

Preview deployment: https://sentry-r2t7ormgg.sentry.dev

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

Stale Bugbot comment from a previous run.

Comment thread static/app/views/dashboards/widgetBuilder/components/thresholds.tsx Outdated
@TkDodo TkDodo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Sep 18, 2026
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Sep 18, 2026
@TkDodo TkDodo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Sep 18, 2026
@TkDodo

TkDodo commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

bugbot run

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c9d704a. Configure here.

@TkDodo
TkDodo merged commit 2cd12ae into master Sep 18, 2026
93 of 94 checks passed
@TkDodo
TkDodo deleted the seer/fix-widget-thresholds-crash branch September 18, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant