Skip to content

fix(versioning): don't record save-path defaults as user changes - #45352

Merged
aminghadersohi merged 5 commits into
apache:masterfrom
mikebridge:sc-126894-default-settings-noise
Oct 19, 2026
Merged

aminghadersohi merged 5 commits into
apache:masterfrom
mikebridge:sc-126894-default-settings-noise

Conversation

@mikebridge

@mikebridge mikebridge commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

TL;DR: Version history listed settings nobody touched as changes. A dashboard's first save showed about 10 "Set '…'" rows for default settings, and a chart save showed "Set 'conditional formatting'". This PR stops recording those, so a save lists only what the user actually changed.

Background: When a dashboard is saved, Superset fills in default values for metadata settings it doesn't have yet (refresh_frequency: 0, label_colors: {}, and so on). A dashboard created from Explore's Save modal ("Add to dashboard → create new") has none of them until its first full save. In Explore, the Conditional Formatting control wrote [] into the chart's form data as soon as it appeared. Opening the Customize tab was enough.

Problem: Version history compares the saved state before and after each save. It counted "setting missing → default value" as a user change:

  • A dashboard save with 3 real edits listed 14 rows plus "Show 4 more".
  • A Big Number save listed "Set 'conditional formatting'" although the control still showed "Add new color formatter".

The real changes got buried, and the history claimed the user "set" things they never touched.

What this changes:

  • Charts (ConditionalFormattingControl): the control no longer echoes its value back when it mounts. It reports formatters only after the user adds, edits or removes one. Every renderer that reads conditional_formatting already treats a missing value like []:

    • table, AG Grid table, pivot table, Big Number and country map, through getColorFormatters and ?./|| [];
    • no buildQuery reads it.

    Charts that already store [] behave as before. This also fixes a case where the earlier mount echo could overwrite formatters hydrated into an already-mounted control, for example an in-place version restore. A test covers it.

  • Dashboards (superset/versioning/diff.py): when version history records a save, a json_metadata key that was missing before the save and is set to exactly the save path's own default is not recorded.

    • The 10 keys: chart_customization_config, color_scheme_domain, cross_filters_enabled, default_filters, expand_all_slices, expanded_slices, label_colors, native_filter_configuration, refresh_frequency, timed_refresh_immune_slices.
    • Where the defaults come from: saveDashboardRequest, the HYDRATE_DASHBOARD reducer, and DashboardDAO.set_dash_metadata.
    • Still recorded:
      • missing → any other value;
      • default → another value;
      • another value → the default;
      • a stored null → anything (a null cross_filters_enabled means "disabled" in the UI).

    The match is type-strict, so 1 is not True.

Why not extend #43350: #43350 handles "accurate chart version changes". Explore sends evidence of what its own hydration normalized, and capture ignores those differences. That fix deliberately covers only existing-chart overwrites from Explore. It deliberately trusts only differences produced during hydration; any later write counts as a real change. It also explicitly leaves dashboards out of scope. Neither case here fits:

  • The Conditional Formatting write happens after hydration, when the control mounts.
  • Dashboards have no evidence pipeline.

Fixing the source (the control) and adding a small, explicit defaults table for dashboards keeps #43350's safety rules intact.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No screenshots; this changes which history rows are recorded, not how they look. Examples from the two QA repros:

Dashboard: created from Explore's Save modal, then Edit properties → change title, slug and description → Save.

Before After
14 rows + "Show 4 more": Added chart '…', title, slug, description, plus Set 'timed refresh immune slices', 'refresh frequency', 'native filter configuration', 'label colors', 'expanded slices', 'expand all slices', 'default filters', 'cross filters enabled', 'color scheme domain', 'chart customization config' Added chart '…', title, slug, description

Chart: Big Number, with name, Subtitle and Show Metric Name changed in one save.

Before After
Set 'subtitle' · Changed 'show metric name' · Chart renamed to '…' · Set 'conditional formatting' Set 'subtitle' · Changed 'show metric name' · Chart renamed to '…'

TESTING INSTRUCTIONS

Automated:

pytest tests/unit_tests/versioning/test_diff_save_defaults.py
cd superset-frontend && npm run test -- src/explore/components/controls/ConditionalFormattingControl

The new tests cover:

  • both repros at unit level;
  • the dashboard negative controls: missing → non-default, default changed later, value changed back to the default, null → default, type strictness, and keys outside the table;
  • chart params still recording missing → [] (fix(versioning): suppress automatic chart normalization changes #43350's rule is unchanged);
  • the control:
    • doesn't write on mount (unset or []);
    • doesn't overwrite a value supplied after mount;
    • still reports adding a formatter and removing the last one.

Manual, with VERSION_HISTORY on (the default):

  1. In Explore, save a chart to a new dashboard. Open the dashboard → Edit dashboard → ⋯ → Edit properties → change only the title, slug and description → Apply → Save. Open ⋯ → View version history: the save lists "Added chart" plus the three edits, with no "Set '…'" rows for settings you didn't touch.
  2. Open a Big Number chart, open the Customize tab, change the name, Subtitle and Show Metric Name → Save (Overwrite). The history entry has no "Set 'conditional formatting'" row.
  3. Add a conditional formatter, save, then remove it and save again. Both saves are recorded.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: VERSION_HISTORY (on by default; affects which version-history rows are recorded)
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Notes:

  • Recording only. The dashboard change applies when a save is recorded. History stored before this change keeps its existing rows, and restore is unaffected (it reads the stored versions, not these change rows).
  • Review: reviewed independently by a second model family, with no behavioural findings. The one follow-up it asked for, test annotations, is in the second commit.
  • Known follow-up, not in this PR: a save whose only change is missing → defaults (for example, a dashboard created through the API without metadata, then saved with no edits) can still leave an empty "Properties updated" version. That's because the version-row skip check in superset/versioning/factory.py (_normalize_dashboard_json_metadata) still compares those defaults. Aligning it changes when version rows are written, so it's kept separate. It isn't reachable in the repros above, because those saves always record the chart add.

mikebridge and others added 2 commits October 15, 2026 11:23
A dashboard created from Explore's Save modal has none of the metadata keys
its first full save fills in (refresh_frequency, label_colors, ...), so
version history listed every default as "Set '<key>'" beside the user's
real edits. A json_metadata key that goes from missing to exactly the value
the save path writes for it no longer produces a change record; moving it
to any other value, or away from its default later, still does.

Explore's Conditional Formatting control echoed its value back on mount, so
opening the Customize tab wrote [] into an untouched chart's form data
("Set 'conditional formatting'"). The control now reports formatters only
after the user adds, edits or removes one. Every renderer already treats a
missing value like [].

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mikebridge
mikebridge marked this pull request as ready for review October 15, 2026 17:19
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; the changes address spurious version-history entries without suppressing explicit formatter edits.
  • The dashboard metadata defaults are narrowly scoped, and the tests cover default saves, non-default changes, null values, and type mismatches.
  • The conditional-formatting tests cover untouched values and adding or removing formatters.

Assessed commit: a9ce18515e59

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (f0cfaff) to head (a9ce185).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #45352   +/-   ##
=======================================
  Coverage   83.57%   83.57%           
=======================================
  Files        3049     3049           
  Lines      199985   200001   +16     
  Branches    46650    46653    +3     
=======================================
+ Hits       167133   167148   +15     
- Misses      29610    29611    +1     
  Partials     3242     3242           
Flag Coverage Δ
hive 34.92% <31.25%> (-0.01%) ⬇️
javascript 79.25% <100.00%> (-0.01%) ⬇️
mysql 52.93% <100.00%> (+<0.01%) ⬆️
postgres 52.94% <100.00%> (+<0.01%) ⬆️
presto 36.68% <50.00%> (+<0.01%) ⬆️
python 87.11% <100.00%> (+<0.01%) ⬆️
sqlite 52.70% <100.00%> (+<0.01%) ⬆️
unit 81.21% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Please remove the private tracker references.

Comment thread superset/versioning/diff.py Resolved
@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit a9ce185
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ad673687cf772d73b30aac0
😎 Deploy Preview https://deploy-preview-45352--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Approved.

@aminghadersohi
aminghadersohi merged commit d36febc into apache:master Oct 19, 2026
81 checks passed
sadpandajoe added a commit that referenced this pull request Oct 22, 2026
…ntrols

Resolve ConditionalFormattingControl.test.tsx: keep both sides' tests. Master's
file-level FormattingPopover stub replaced the real popover the CRUD tests
drive, so the stub is dropped and the add/remove test uses the real popover.
Two prune tests no longer expect the mount-time onChange echo removed in #45352.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants