fix(explore): stop metric edits from bleeding across metrics with duplicate optionNames#41208
Draft
jesperct wants to merge 2 commits into
Draft
fix(explore): stop metric edits from bleeding across metrics with duplicate optionNames#41208jesperct wants to merge 2 commits into
jesperct wants to merge 2 commits into
Conversation
…ss metrics Metrics are matched by optionName when an edit is saved, but a saved chart can carry two adhoc metrics sharing the same optionName (e.g. born from a duplicated metric). Editing one then overwrote every metric with that optionName. coerceAdhocMetrics now regenerates colliding optionNames on load so each metric keeps a unique identity.
The drag-and-drop metric control (used by current Explore) matches edits by optionName the same way the legacy control does, so it shares the same bug: editing one of two metrics with a duplicate optionName rewrote both. Apply the same uniqueness fix in coerceMetrics, verified live.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41208 +/- ##
=======================================
Coverage 64.33% 64.33%
=======================================
Files 2651 2651
Lines 144766 144779 +13
Branches 33401 33405 +4
=======================================
+ Hits 93131 93145 +14
+ Misses 49965 49964 -1
Partials 1670 1670
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Editing one custom (adhoc) metric could silently rewrite other metrics on the same chart. When a chart's saved metrics include two adhoc metrics that share an
optionName(which can happen, for example after duplicating a metric), editing one of them overwrote every metric with thatoptionName— both the label and the definition snapped to the edited one.Root cause: the metric controls match an edit back to its metric by
optionName, but nothing guaranteedoptionNamewas unique. This fixes it where metrics are loaded into the control (coerceMetrics/coerceAdhocMetrics): a metric whoseoptionNamecollides with an earlier one is given a freshoptionName, so each metric keeps a unique identity. That both heals already-affected saved charts and prevents the behavior going forward. The fix is applied to the drag-and-drop metric control used by Explore and to the legacy metrics control, which share the same matching logic.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: editing one metric's aggregate (SUM → MAX) also changes the second metric, leaving two identical
MAX(num)metrics.After: only the edited metric changes; the second metric stays
AVG(num).TESTING INSTRUCTIONS
form_dataholds two adhoc metrics on the same column that share anoptionName(this is the state a duplicated metric can leave behind).DndMetricSelect.test.tsxandMetricsControl.test.tsxassert that loading two metrics with a duplicateoptionNameyields unique identities so an edit touches only one.ADDITIONAL INFORMATION