Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/testcontainers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ on:
paths:
- ".github/workflows/testcontainers.yml"
- "tests/testcontainers/**"
- "!tests/testcontainers/versioning/**"
- "superset/db_engine_specs/**"
- "pyproject.toml"
- "requirements/development.in"
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/versioning-testcontainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Version history databases

permissions:
contents: read

on:
schedule:
- cron: "0 5 * * *"
workflow_dispatch: {}
pull_request:
paths:
- ".github/workflows/versioning-testcontainers.yml"
- ".github/actions/setup-backend/**"
- "tests/testcontainers/versioning/**"
- "tests/testcontainers/db_engine_specs/_driver.py"
- "tests/conftest.py"
- "tests/integration_tests/test_app.py"
- "tests/integration_tests/superset_test_config.py"
- "pytest.ini"
- "superset/versioning/**"
- "superset/commands/deletion_retention/purge_cascade.py"
- "superset/tasks/version_history_retention.py"
- "superset/migrations/versions/2026-11-23_00-00_a7d29bc4e681_add_chart_archive_scope.py"
- "superset/migrations/shared/utils.py"
- "superset/initialization/__init__.py"
- "superset/app.py"
- "superset/config.py"
- "superset/models/slice.py"
- "superset/models/dashboard.py"
- "superset/models/helpers.py"
- "pyproject.toml"
- "requirements/base.in"
- "requirements/base.txt"
- "requirements/development.in"
- "requirements/development.txt"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
archive-history:
if: github.event_name != 'schedule' || github.repository == 'apache/superset'
runs-on: ubuntu-26.04
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
dialect: [POSTGRES, MYSQL]
env:
PYTHONPATH: ${{ github.workspace }}
SUPERSET_TESTENV: true
SUPERSET_SECRET_KEY: not-a-secret
SUPERSET_TESTCONTAINERS_STRICT: true
SUPERSET_VERSIONING_TEST_DIALECT: ${{ matrix.dialect }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Python
uses: $/.github/actions/setup-backend/
with:
python-version: current
- name: Run archive transaction and migration tests
run: |
pytest --durations-min=2 -v -m testcontainers \
tests/testcontainers/versioning/test_chart_archive.py \
--junit-xml=test-results/junit-archive-${{ matrix.dialect }}.xml
- name: Upload JUnit test results
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: junit-results-archive-${{ matrix.dialect }}
path: test-results/
retention-days: 7
17 changes: 17 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ assists people when migrating to a new version.

## Next

- Dashboard history records related chart archives using the new
`version_chart_archive_scope` table. Run `superset db upgrade` before deploying
new archive writes with versioning capture enabled. During a rollout, activity
reads tolerate a missing scope table and continue returning content history;
archive capture skipped before the migration cannot be reconstructed or
backfilled. Archive activity adds no content version and does not change
recovery or content-restore behavior. Downgrade removes archive scopes and
archive records but leaves content history intact; empty activity transactions
may remain until normal history retention removes them.

- Version-history commit-time finalization rejects the whole save when a database
error occurs outside a recoverable savepoint, including final field or child
diff generation and version-transaction lookup. This applies to ordinary
content saves as well as chart archives. A lost transaction or savepoint also
rejects the save. Optional capture failures isolated by a successful savepoint
rollback may still omit history without rejecting the save.

- Semantic-view user exclusions (`!=`, non-empty `NOT IN` without NULL, `NOT LIKE`, and `NOT ILIKE`) reach providers as an OR group with `IS_NULL`; upgrade leaf-only adapters before deploying the host, even if they accepted those operators before. See the [provider filter contract](docs/developer_docs/extensions/extension-points/semantic-layers.md#filter-expressions).

- Semantic views reject Histogram, Calendar Heatmap, Time-series Table, Time-series
Expand Down
50 changes: 50 additions & 0 deletions docs/docs/using-superset/version-history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ stops filling — an empty or stale history misrepresents the entity as
unchanged. History only accrues while capture is on; edits made while it was
off are not reconstructed.

At commit time, an optional history-capture failure isolated by a successful
savepoint rollback may omit history while allowing the save to succeed. A database
error outside that isolation, or a lost transaction or savepoint, rejects the
whole save. This applies to ordinary content saves as well as archive operations:
Superset does not report success when it cannot establish that the user's changes
survived the capture failure.

## Retention

The `version_history.prune_old_versions` background task prunes expired
Expand Down Expand Up @@ -375,6 +382,49 @@ you are looking at.
Changes made outside a save, such as ownership or permission edits, are not part
of version history.

### Chart archive activity on dashboards

With `SOFT_DELETE` and versioning capture enabled, archiving a chart records
an archive event for each dashboard containing it at capture time.
`VERSION_HISTORY` controls whether the UI and supporting APIs expose that activity;
turning it off does not stop archive capture. With the flag enabled, dashboards
show **Chart archived: <chart name>** in related activity. Bulk archives show
one entry per chart. The entry uses the chart's name and the archive capture time, and remains
an archive entry after the chart is recovered. Chart history itself contains only
content activity.

Membership is captured after the archive transaction's changes have been flushed.
A chart attached while capture was disabled can therefore appear in its dashboard's
archive activity; one detached during that interval does not. Later membership
changes do not move old archive entries between dashboards. Archived dashboards
retain their captured membership and can show the activity after recovery.
A dashboard with no saved content history can show archive activity without an
**Original version** entry.

Archive entries have no content preview, restore-version, or open-as-new action.
Archived charts do not link to Explore; recovering a chart enables the link again.
Recover charts through **Recently Archived**: restoring a content version does not
unarchive them. Explicit recovery events are not recorded. The chart's last content
version remains current after recovery without another save.

History permissions still apply: dashboard history requires edit access, related
names require access to the related resource, and actor and raw change details
require edit access to that resource. For archived related resources, actor and
raw detail remain hidden from non-Admin readers, including the archiver. The panel
labels a hidden or unavailable actor **System**; this label does not establish that
the action was automated.

Permanent purge removes a chart's archive entries from all dashboards, even when history retention is disabled or longer
than archive retention. Normal history retention can also remove expired archive
activity; archive membership does not keep expired transactions alive.

Deploy the database migration before enabling archive capture. Archives made with
capture disabled, denied by host policy, or skipped because capture storage was
unavailable are not backfilled. If capture was disabled during archive and a later
write creates the first content baseline, its attribution comes from the archived
row's stored audit fields and can credit the archiver; it does not reconstruct an
archive event.

### Resuming capture after a disabled interval

When a dataset or dashboard snapshot is saved with capture enabled, its child
Expand Down
11 changes: 6 additions & 5 deletions docs/static/resources/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"type": "string"
},
"entity_name": {
"description": "Name of the source entity *at the time of the change* \u2014 denormalized from the validity-strategy shadow row. Survives entity rename / delete.",
"description": "Name of the source entity *at the time of the change* \u2014 denormalized from the validity-strategy shadow row, or from the capture-time payload for ``__archive__`` records. Preserved across renames; redacted for deleted related entities.",
"type": "string"
},
"entity_uuid": {
Expand Down Expand Up @@ -322,7 +322,7 @@
"type": "string"
},
"kind": {
"description": "Content category \u2014 what kind of thing changed. ``field`` is the fallback for scalar changes without a more specific category. Per-record.",
"description": "Content category \u2014 what kind of thing changed. ``field`` is the fallback for scalar changes without a more specific category. Per-record. ``__archive__`` announces a chart archive in related dashboard activity only.",
"enum": [
"filter",
"metric",
Expand All @@ -339,7 +339,8 @@
"color_palette",
"field",
"__meta__",
"__creation__"
"__creation__",
"__archive__"
],
"type": "string"
},
Expand Down Expand Up @@ -372,11 +373,11 @@
"type": "string"
},
"summary": {
"description": "Synthesized headline for ``source: \"related\"`` records \u2014 e.g., ``\"Dataset updated: Sales Transactions\"``. Empty string for ``source: \"self\"`` records, except ``__meta__`` self records (e.g. restore announcements), which carry their own headline.",
"description": "Synthesized headline for ``source: \"related\"`` records \u2014 e.g., ``\"Dataset updated: Sales Transactions\"`` or ``\"Chart archived: Sales\"``. Empty string for ``source: \"self\"`` records, except ``__meta__`` self records (e.g. restore announcements), which carry their own headline.",
"type": "string"
},
"to_value": {
"description": "New value; ``null`` = removed.",
"description": "New value; ``null`` = removed. For ``__archive__``, an object with the archived chart's ``entity_uuid`` and capture-time ``entity_name``; null when related detail is redacted.",
"nullable": true
},
"transaction_id": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,56 @@ test('a row whose records span several kinds of change gets a neutral headline',
).toBeInTheDocument();
expect(screen.queryByText(/metric changed/)).not.toBeInTheDocument();
});

test.each([
{
entity_deleted: false,
entity_deletion_state: 'soft_deleted',
entity_uuid: 'abc',
},
{ entity_deleted: true, entity_deletion_state: null, entity_uuid: 'abc' },
{ entity_deleted: false, entity_deletion_state: null, entity_uuid: null },
])(
'unavailable related charts have no links or version actions: %s',
unavailable => {
render(
<RelatedUpdateRow
record={{
...baseRecord,
entity_kind: 'chart',
kind: '__archive__',
operation: 'announce',
impact: null,
path: null,
to_value: null,
...unavailable,
}}
onOpen={jest.fn()}
/>,
);
expect(screen.queryByRole('button')).not.toBeInTheDocument();
expect(screen.queryByText('Preview')).not.toBeInTheDocument();
expect(screen.queryByText('Restore this version')).not.toBeInTheDocument();
expect(screen.queryByText('Open as new chart')).not.toBeInTheDocument();
},
);

test('a recovered chart links from its archive event and keeps shared author formatting', async () => {
const onOpen = jest.fn();
const archive: ActivityRecord = {
...baseRecord,
entity_kind: 'chart',
kind: '__archive__',
operation: 'announce',
impact: null,
path: null,
to_value: null,
};
render(<RelatedUpdateRow record={archive} onOpen={onOpen} />);
expect(screen.getByText(/Chart archived:/)).toBeInTheDocument();
expect(screen.getByText(/System ·/)).toBeInTheDocument();
await userEvent.click(
screen.getByRole('button', { name: 'Sales Transactions' }),
);
expect(onOpen).toHaveBeenCalledWith(archive);
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { styled } from '@apache-superset/core/theme';
import { Icons, Tooltip } from '@superset-ui/core/components';
import type { IconType } from '@superset-ui/core/components/Icons/types';
import type { ActivityEntityKind, ActivityRecord } from './types';
import { canOpenRelatedEntity } from './lifecycle';
import {
entityDisplayName,
formatAuthor,
Expand Down Expand Up @@ -202,7 +203,7 @@ export default function RelatedUpdateRow({
impactCount,
);
}
const linkable = !record.entity_deleted && Boolean(onOpen);
const linkable = canOpenRelatedEntity(record) && Boolean(onOpen);
// Both the server summary and the impact-aware phrasing end with the
// entity name; split it out so the name can render as a link. Records
// without a name can't be split (the empty string matches anywhere).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,23 @@ test('leaves the panel unchanged when no footer is registered', () => {
expect(screen.getByText('No history yet')).toBeInTheDocument();
expect(screen.queryByRole('note')).not.toBeInTheDocument();
});

test('an archive-only dashboard shows activity without a fabricated content version', () => {
const timeline = buildTimeline([
record({
source: 'related',
kind: '__archive__',
operation: 'announce',
version_uuid: null,
entity_deletion_state: 'soft_deleted',
path: null,
to_value: null,
}),
]);
render(<VersionHistoryPanel {...defaultProps(timeline, 'dashboard')} />);
expect(screen.getByText('Chart archived: My chart')).toBeInTheDocument();
expect(screen.queryByText('No history yet')).not.toBeInTheDocument();
expect(screen.queryByText('Original version')).not.toBeInTheDocument();
expect(screen.queryByText('Restore this version')).not.toBeInTheDocument();
expect(screen.queryByText('Preview')).not.toBeInTheDocument();
});
Loading
Loading