Skip to content

fix(versioning): show chart archival in dashboard history - #46479

Merged
rebenitez1802 merged 5 commits into
apache:masterfrom
rebenitez1802:fix/chart-archive-dashboard-history
Nov 23, 2026
Merged

rebenitez1802 merged 5 commits into
apache:masterfrom
rebenitez1802:fix/chart-archive-dashboard-history

Conversation

@rebenitez1802

Copy link
Copy Markdown
Contributor

SUMMARY

Archiving a chart does not create a content version, so dashboard version history previously gave no indication that the chart had been archived. This adds a separate Chart archived: related-activity entry for each dashboard containing the chart at archive time, including dashboards without a content baseline.

The event stores its historical chart identity/name and dashboard membership in the archive transaction. Membership remains accurate across capture-disabled attaches/detaches and later changes. Chart self-history stays content-only, preserving current-version detection after recovery without another save. Archived entries offer no content-version actions or Explore navigation; recovery enables navigation while retaining the archive headline. Related-resource read permissions, detail editorship, and deletion redaction still apply.

Two related transaction policies are explicit:

  • Optional database capture failures may omit history after a successful savepoint rollback. Lost transactions/savepoints and database errors from unisolated commit-time history reads reject the entire save. This deliberately affects ordinary chart, dashboard, and dataset saves too: on PostgreSQL, swallowing such a read error can report success after the database discarded the user's changes.
  • Managed purge removes archive scopes/events and collects orphan candidates from change-only records and both shadow transaction endpoints. This also improves cleanup for ordinary purges; shared transactions remain while any change, scope, or shadow endpoint references them.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: the chart is archived, but dashboard history contains no archive announcement.

Before: archived chart absent from dashboard history

After: the same archive has a timestamped related entry, while the latest content save remains unchanged.

After: chart archive announcement in dashboard history

Screenshots use an isolated local test dashboard. Browser checks also verified that recovery restores chart navigation without changing the historical archive verb.

TESTING INSTRUCTIONS

  1. Run superset db upgrade. Enable SOFT_DELETE, VERSION_HISTORY, and the ENABLE_VERSIONING_CAPTURE configuration.
  2. Save a chart on a dashboard, then archive it. Dashboard history should show one archive entry with no version actions or chart navigation. Repeat with bulk archive.
  3. Recover the chart without saving its content. The archive entry should remain and allow navigation; chart history should still identify its last content save as current.
  4. Attach or detach a chart while capture is disabled, re-enable capture, then archive it. Only dashboards containing it at archive time should receive the entry. An untracked dashboard should not receive a fabricated Original version.
  5. Permanently purge the chart and verify its archive entries disappear. Verify that a dashboard editor without access to the related resource cannot see its archive activity.

Local validation across implementation and review rounds:

  • 694 backend unit tests; 13 archive API cases and 112 selected existing soft-delete/restore/purge/retention cases.
  • 132 frontend tests, with 54 relevant tests rerun for the headline/probe review changes; full TypeScript checking passed.
  • 13 PostgreSQL/MySQL Testcontainers cases passed, with one intentional PostgreSQL skip for the MySQL-only timeout case. These exercise real deadlocks, lock timeouts, missing-scope reads/writes, migration reruns/cascades, and content-write failures without phantom archive events.
  • Purge query counts are 42/41/51 for chart/dashboard/dataset fixtures; the three budget checks passed.
  • Branch-scoped pre-commit and mypy passed before push, including direct/committed-diff pylint coverage. Translation drift, stable OpenAPI generation, and the single migration head were checked.

The dedicated PostgreSQL/MySQL workflow runs pytest -m testcontainers tests/testcontainers/versioning/test_chart_archive.py automatically. Hosted checks are pending this PR.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SOFT_DELETE for archive operations; VERSION_HISTORY for displaying history. ENABLE_VERSIONING_CAPTURE is a separate capture configuration; turning off VERSION_HISTORY does not stop capture.
  • 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

Migration a7d29bc4e681 creates an empty archive-scope table and indexes; it does not backfill events or rewrite existing entity tables. Upgrade before new archive writes. Missing-table reads preserve content history, but skipped archives cannot be reconstructed. Downgrade removes archive scopes/events, preserves content history, and leaves empty transactions for normal retention. SQLite, PostgreSQL 17, and MySQL 8.0 upgrade/downgrade and rerun behavior were tested. The combined atomicity checkbox is intentionally unchecked because MySQL DDL is not transactional.

Measured empty-database upgrade time was approximately 14–18 ms on PostgreSQL and 32–42 ms on MySQL; downgrade was approximately 7 ms and 17 ms respectively. These measurements exclude concurrent workload and metadata-lock waits. DDL needs metadata locks, so production lock waits remain deployment-dependent; zero downtime is not claimed.

Recheck migration parentage if #45022 lands first: both migrations descend from dfa683969f48. Preserve both version-table cleanup inventory additions when resolving that integration.

Explicit recovery events remain deferred. Non-Admin readers cannot see archived related actor/details under the existing policy; the panel labels a withheld actor as System. This targets master; no 7.0.x backport is included.

AI-assisted implementation and PR description. Three internal review rounds were completed, and their actionable findings were addressed. The local test and browser results above were executed during implementation; this does not claim hosted CI has passed.

Keep commit-time version-history finalization fail closed on unisolated
DBAPI errors. This policy applies to ordinary chart, dashboard, and dataset
saves as well as archives: a failed read can abort PostgreSQL's transaction,
so swallowing it can report success after the user's changes were rolled
back. Optional database capture failures isolated by a successful savepoint
rollback may still omit history without rejecting the save. Document this
policy in the user guide, upgrade notes, and finalization docstrings.

Suppress expected missing-scope tracebacks while retaining error metrics;
log and count fatal archive capture before propagating it. Restrict lost
transaction diagnostics to database-driver errors and add null-UUID
membership coverage. Scope CI workflows to their actual dependencies and
make the versioning Testcontainers suite an explicit Python package.
@github-actions github-actions Bot added i18n Namespace | Anything related to localization doc Namespace | Anything related to documentation github_actions Pull requests that update GitHub Actions code labels Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.87871% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.97%. Comparing base (d0e2161) to head (c29aa3c).

Files with missing lines Patch % Lines
superset/versioning/lifecycle.py 93.91% 5 Missing and 4 partials ⚠️
...erset/commands/deletion_retention/purge_cascade.py 80.76% 1 Missing and 4 partials ⚠️
superset/versioning/activity/queries.py 97.22% 1 Missing and 1 partial ⚠️
superset/versioning/factory.py 83.33% 2 Missing ⚠️
superset/versioning/changes/listener.py 97.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46479      +/-   ##
==========================================
+ Coverage   85.93%   85.97%   +0.03%     
==========================================
  Files        3123     3127       +4     
  Lines      217179   217726     +547     
  Branches    51489    51618     +129     
==========================================
+ Hits       186634   187183     +549     
  Misses      27119    27119              
+ Partials     3426     3424       -2     
Flag Coverage Δ
hive 33.82% <15.34%> (-0.05%) ⬇️
javascript 82.79% <100.00%> (+0.03%) ⬆️
mysql 51.61% <71.59%> (+0.05%) ⬆️
postgres 51.64% <71.30%> (+0.05%) ⬆️
presto 35.50% <22.72%> (-0.04%) ⬇️
python 88.47% <94.60%> (+0.03%) ⬆️
sqlite 51.31% <71.30%> (+0.05%) ⬆️
unit 83.96% <92.61%> (+0.08%) ⬆️

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.

Archive capture, membership scoping, visibility gating, purge cleanup and the migration look correct.

Nit: RelatedUpdateRow.test.tsx: the Preview/Restore/Open as new chart absence checks can never fail; that row never renders them.

@rebenitez1802

Copy link
Copy Markdown
Contributor Author

@aminghadersohi Thanks for the review! Fixed the nit in 7a12fda: removed the three redundant action assertions and renamed the test to describe the navigation-link check it actually exercises. The button-absence assertion remains.

All 11 focused tests and branch-wide pre-commit checks passed.

@rebenitez1802
rebenitez1802 merged commit b13ab50 into apache:master Nov 23, 2026
107 checks passed
geido added a commit that referenced this pull request Nov 23, 2026
The Canvas tip 638c287 merges master b13ab50 (#46479), so this
brings the current master too. #46479's chart archive scope migration
sits under the canvas migrations, as the Canvas tip re-points them.

Conflicts: UPDATING.md (kept both sides' entries) and messages.pot
(took master's creation date).

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

Labels

doc Namespace | Anything related to documentation github_actions Pull requests that update GitHub Actions code i18n Namespace | Anything related to localization risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants