-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(dashboards): Persist legend selection to URL for new chart widgets #112974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import {t} from 'sentry/locale'; | ||
| import {maybeEquationAlias, stripEquationPrefix} from 'sentry/utils/discover/fields'; | ||
| import {formatVersion} from 'sentry/utils/versions/formatVersion'; | ||
| import {WidgetLegendNameEncoderDecoder} from 'sentry/views/dashboards/widgetLegendNameEncoderDecoder'; | ||
| import type {TimeSeries} from 'sentry/views/dashboards/widgets/common/types'; | ||
|
|
||
| export function formatTimeSeriesLabel(timeSeries: TimeSeries): string { | ||
|
|
@@ -34,9 +33,6 @@ export function formatTimeSeriesLabel(timeSeries: TimeSeries): string { | |
|
|
||
| let {yAxis: seriesName} = timeSeries; | ||
|
|
||
| // Decode from series name disambiguation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing decode also removes function name prettificationLow Severity The removed Reviewed by Cursor Bugbot for commit 243cd0f. Configure here. |
||
| seriesName = WidgetLegendNameEncoderDecoder.decodeSeriesNameForLegend(seriesName)!; | ||
|
|
||
| // Attempt to parse the `seriesName` as a version. A correct `TimeSeries` | ||
| // would have a `yAxis` like `p50(span.duration)` with a `groupBy` like | ||
| // `[{key: "release", value: "proj@1.2.3"}]`. `groupBy` was only introduced | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
encodeLegendSelectionis called with anundefinedwidget.idfor unsaved widgets, creating invalid legend keys. Downstream decoding logic using a non-null assertion onwidget.idwill then fail.Severity: LOW
Suggested Fix
Add explicit validation in
widgetCanUseTimeSeriesVisualizationto ensure a widget has an ID before allowing legend state changes. Alternatively, defensively handleundefinedIDs in the encoder and decoder functions to prevent creating invalid keys.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.