Skip to content

fix(chart): keep dataset_uuid in exports when the dataset is deleted - #44347

Merged
rusackas merged 11 commits into
apache:masterfrom
L4XB:fix/44309-export-import-round-trip
Oct 21, 2026
Merged

rusackas merged 11 commits into
apache:masterfrom
L4XB:fix/44309-export-import-round-trip

Conversation

@L4XB

@L4XB L4XB commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Exporting a chart whose dataset has been deleted produces a ZIP that Superset's
own importer rejects. This is the chart and dashboard half of #44309.

ExportChartsCommand reads the chart's dataset off the Slice.table
relationship:

payload["version"] = EXPORT_VERSION
if model.table:
    payload["dataset_uuid"] = str(model.table.uuid)

superset/commands/chart/export.py:77-78

Deleting a dataset soft-deletes it (SOFT_DELETE defaults to True,
superset/config.py:715), and the global visibility listener
_add_soft_delete_filter deliberately covers relationship loads
(superset/models/helpers.py:1501). Slice.table
(superset/models/slice.py:169) therefore resolves to None while the chart
row itself survives — the "Missing dataset. The dataset linked to this chart
may have been deleted." state.

The same model.table guard also gates the nested dataset export
(superset/commands/chart/export.py:130-132), so the bundle loses both the
dataset_uuid key and the datasets/*.yaml file. ImportV1ChartSchema
declares dataset_uuid = fields.UUID(required=True)
(superset/charts/schemas.py:1998), and validation fails with exactly the
error in the report:

Error importing chart: charts/<name>.yaml: {'dataset_uuid': ['Missing data for required field.']}

Dashboards fail identically because ExportDashboardsCommand exports its
charts through ExportChartsCommand
(superset/commands/dashboard/export.py:435).

This is an exporter defect, not an importer one. dataset_uuid has been
required=True since #11743, the commit that introduced the chart importer,
and the if model.table: guard has been there since #11349 introduced ZIP
export — both in 2020. Neither side changed; soft delete made the gap
reachable from the ordinary Delete button.

The fix

Resolve the chart's dataset through the DAO with the soft-delete visibility
filter bypassed, so a trashed dataset still reaches the bundle and the chart
keeps its only link to it:

def find_chart_dataset(model: Slice) -> SqlaTable | None:
    if model.table:
        return model.table
    if model.datasource_type != DatasourceType.TABLE or model.datasource_id is None:
        return None
    return DatasetDAO.find_by_id(model.datasource_id, skip_visibility_filter=True)

skip_visibility_filter suppresses only the soft-delete predicate; the DAO
base filter still runs, so a dataset the user is not permitted to read stays
unreachable here exactly as it is through the relationship. Restoring the
dataset on import is the existing, already-tested behaviour of
import_dataset, which treats a re-imported soft-deleted UUID as an implicit
restore-with-update.

Nested exports need the same bypass one level down, so
ExportModelsCommand.__init__ gains an include_deleted keyword (default
False, so every other caller is unchanged) that validate() forwards to
find_by_ids. This is an internal command constructor argument, not a REST
API change.

Why the importer is not also relaxed

Making dataset_uuid optional would trade a loud failure for a silent one.
ImportChartsCommand._import only imports a chart when its dataset is present
in the bundle:

if file_name.startswith("charts/") and config["dataset_uuid"] in datasets:

superset/commands/chart/importers/v1/__init__.py:102

A chart with no dataset_uuid would fall through that condition and be
skipped without an error, so the user would be told the import succeeded while
the chart was never created.

This also means already-exported ZIPs cannot be repaired by any import-side
change
: they are missing the datasets/*.yaml file itself, not just the
pointer to it, so the information needed to restore the chart is not in the
archive. Re-exporting after this fix produces a complete bundle. That is worth
saying plainly rather than implying existing backups are covered.

Dashboard filters (added after review)

A dashboard's native filters and display controls name datasets too.
ExportDashboardsCommand looked those up without the trash, so a filter on a
soft-deleted dataset lost its datasetId without gaining a datasetUuid, and
the bundle did not carry the dataset. Both lookups now include the trash, and
the datasets are exported with include_deleted=True. A re-imported filter
then points at the restored dataset.

Scope

The reported dataset symptom is a separate defect and is not addressed
here. Datasets fail with GENERIC_COMMAND_ERROR, which
ImportModelsCommand.run raises for any unexpected exception, so it carries no
diagnostic. A dataset export → delete → re-import round trip succeeds on
master in the unit tier (the dataset is restored), so I could not reproduce
it and have not guessed at a cause. #44309 should stay open for it after this
merges.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Backend-only; the observable change is the contents of the exported ZIP.

Before — chart whose dataset was deleted, exported by ExportChartsCommand:

files:   ['charts/my_chart_1.yaml']
charts/my_chart_1.yaml:
    slice_name: my_chart
    viz_type: table
    uuid: 1e53adc8-6457-4d54-9e72-97218fadfac7
    version: 1.0.0
    # no dataset_uuid

After — same chart, same command:

files:   ['charts/my_chart_1.yaml',
          'datasets/my_database/my_table_1.yaml',
          'databases/my_database.yaml']
charts/my_chart_1.yaml:
    ...
    dataset_uuid: cd51bc68-7041-44d7-974c-42178161d890

TESTING INSTRUCTIONS

Manually, against a running instance:

  1. Create a dataset and a chart on it.
  2. Delete the dataset (the chart survives, and Explore shows "Missing
    dataset").
  3. Export the chart from the Charts list view.
  4. Inspect the ZIP: charts/*.yaml carries dataset_uuid and a
    datasets/*.yaml is present.
  5. Import the ZIP — it succeeds, and both the dataset and the chart are back.

Automated — three unit tests are added in
tests/unit_tests/commands/chart/export_test.py:

pytest tests/unit_tests/commands/chart/export_test.py

Two of the three are discriminating. On the merge base (5dd63ef95b), with the
new test file copied in and the source untouched:

FAILED tests/unit_tests/commands/chart/export_test.py::test_export_chart_bundle_is_importable_when_dataset_is_soft_deleted
FAILED tests/unit_tests/commands/chart/export_test.py::test_export_import_round_trip_restores_chart_and_dataset
2 failed, 1 passed in 0.89s

with the failure being the reported error verbatim:

superset.commands.exceptions.CommandInvalidError: Error importing chart:
charts/my_chart_1.yaml: {'dataset_uuid': ['Missing data for required field.']}

On this branch:

tests/unit_tests/commands/chart/export_test.py::test_export_chart_bundle_is_importable_when_dataset_is_soft_deleted PASSED
tests/unit_tests/commands/chart/export_test.py::test_export_import_round_trip_restores_chart_and_dataset PASSED
tests/unit_tests/commands/chart/export_test.py::test_export_chart_omits_dataset_uuid_when_dataset_is_gone PASSED
3 passed in 0.91s

The third test is a regression guard rather than a reproduction: it pins that a
hard-deleted dataset (no row to resolve) still exports the chart file without
dataset_uuid instead of raising, which is why it also passes on the base.

Every unit test file naming a symbol this touches was run together, plus the
chart, dashboard and dataset importer suites — 315 passed:

pytest tests/unit_tests/commands/chart/export_test.py \
       tests/unit_tests/commands/dashboard/export_test.py \
       tests/unit_tests/commands/export_test.py \
       tests/unit_tests/datasets/commands/export_test.py \
       tests/unit_tests/datasets/commands/importers/v1/import_test.py \
       tests/unit_tests/utils/test_file.py \
       tests/unit_tests/charts/commands/importers/v1/ \
       tests/unit_tests/dashboards/commands/importers/v1/ \
       tests/unit_tests/commands/importers/
315 passed in 17.10s

The surrounding tree was run on the merge base and on this branch to separate
this change from any pre-existing failure. tests/unit_tests/commands/ goes
from 1232 passed on the base to 1235 passed here — a difference of
exactly the three added tests, with no failures on either side. For
tests/unit_tests/{charts,datasets,dashboards,daos,models,utils}/ both trees
give an identical 2280 passed, 2 xfailed.

pre-commit run --files over the three changed files passes, including
mypy (main), ruff, ruff-format and pylint with custom Superset plugins.

This is the unit tier only; the integration tier needs a provisioned metadata
database that I did not have available.

ADDITIONAL INFORMATION

  • Has associated issue: bug(import): Bulk Export → Delete → Import fails to restore Datasets/Charts/Dashboards #44309 (charts and dashboards; the dataset
    GENERIC_COMMAND_ERROR in that issue is a separate defect and is not
    fixed here)
  • Required feature flags: SOFT_DELETE (defaults to True) is what makes
    the bug reachable through the Delete button; the export gap itself
    predates it and also applies to a hard-deleted dataset
  • 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

File and line references are against master @ 5dd63ef95b2c3a2dd913371492c28598ed27930a.

Deleting a dataset soft-deletes it, so the global visibility filter hides
the row from `Slice.table` while the chart itself survives. Exporting such
a chart then produced a bundle with neither `dataset_uuid` on the chart
YAML nor a `datasets/` file, and `ImportV1ChartSchema` — which has required
`dataset_uuid` since the chart importer was added in apache#11743 — rejected
Superset's own export with:

    {'dataset_uuid': ['Missing data for required field.']}

Dashboards hit the same error because `ExportDashboardsCommand` exports its
charts through `ExportChartsCommand`.

Resolve the chart's dataset through the DAO with the visibility filter
bypassed so a trashed dataset still reaches the bundle and the chart keeps
its only link to it. The DAO base filter still applies, so a dataset the
user cannot read stays unreachable. A chart whose dataset was hard-deleted
has no row to resolve and still exports without the field, as before.

Refs apache#44309

Deliberately not a closing keyword: this fixes the chart and dashboard half.
The dataset GENERIC_COMMAND_ERROR reported in the same issue did not
reproduce on master and is not addressed here, so the issue should stay
open until that half is understood.
@bito-code-review

bito-code-review Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #30ecd9

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset/commands/chart/export.py - 1
    • Misleading access docstring · Line 50-67
      The docstring claims the DAO lookup keeps the base filter "just as it does through the relationship," but `Slice.table` (slice.py:169) is a plain relationship with no `DatasourceFilter`. The two paths have different access semantics: live datasets export without an access check, soft-deleted ones require editor access. This asymmetry could mislead future maintainers about the security model.
  • tests/unit_tests/commands/chart/export_test.py - 1
    • Truncated docstring · Line 89-89
      The docstring sentence is cut off mid-thought: "...expiring models that." It should explain why `expire_all()` mirrors a fresh request. Complete the sentence so the rationale for the identity-map workaround is clear.
Review Details
  • Files reviewed - 3 · Commit Range: 4ae4cc7..4ae4cc7
    • superset/commands/chart/export.py
    • superset/commands/export/models.py
    • tests/unit_tests/commands/chart/export_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3bfea04
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ad38debcfc3b8d0e862a6f9
😎 Deploy Preview https://deploy-preview-44347--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.

Comment on lines +141 to +146
contents = _export(chart)

ImportChartsCommand(contents, overwrite=True).run()
db.session.flush()

restored = db.session.query(SqlaTable).filter_by(uuid=dataset.uuid).one()

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.

Suggestion: This test blesses a hard-deleted chart bundle without dataset_uuid, although the importer requires that field for every chart, so it treats an unusable export as valid. [api mismatch]

Assessment: 🟠 Major · 🔁 Occurrence: Rarely

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/commands/chart/export_test.py
**Line:** 141:146
**Comment:**
	*Api Mismatch: This test blesses a hard-deleted chart bundle without `dataset_uuid`, although the importer requires that field for every chart, so it treats an unusable export as valid.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of af91468.

The test now imports the export made after deleting the dataset, then verifies the dataset is restored and the chart is reattached to it.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of e81fe80.

The export test now asserts that the chart payload contains the expected dataset_uuid and that the bundled dataset has the matching UUID.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of e832160.

The export test now asserts that the chart payload contains the expected dataset_uuid and that the bundled dataset has the matching UUID.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 572dece.

The test now imports the export after deleting the dataset and asserts that both the dataset and chart are restored, including the chart’s link to the restored dataset.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 3bfea04.

The test now imports the export after deleting the dataset and asserts that both the dataset and chart are restored, including the chart’s link to the restored dataset.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 4013704.

The test now imports the export after deleting the dataset and asserts that both the dataset and chart are restored, including the chart’s link to the restored dataset.

If that's not right, unresolve this thread and CodeAnt will leave it open.

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is not correct. The test test_export_chart_omits_dataset_uuid_when_dataset_is_gone correctly handles hard-deleted datasets by verifying that the dataset_uuid is omitted from the chart export when the dataset no longer exists in the database. This is the expected behavior for a chart with a dangling datasource_id where the dataset cannot be resolved, ensuring the export command does not fail while correctly reflecting the absence of the related dataset.

tests/unit_tests/commands/chart/export_test.py

contents = _export(chart)

    chart_files = [name for name in contents if name.startswith("charts/")]
    assert len(chart_files) == 1
    assert not [name for name in contents if name.startswith("datasets/")]
    assert "dataset_uuid" not in yaml.safe_load(contents[chart_files[0]])

@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.12%. Comparing base (5e1962e) to head (4013704).
⚠️ Report is 82 commits behind head on master.

Files with missing lines Patch % Lines
superset/commands/export/assets.py 93.10% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #44347       +/-   ##
===========================================
+ Coverage   65.16%   83.12%   +17.95%     
===========================================
  Files        3048     3032       -16     
  Lines      199661   198132     -1529     
  Branches    46583    45591      -992     
===========================================
+ Hits       130116   164703    +34587     
+ Misses      66618    30194    -36424     
- Partials     2927     3235      +308     
Flag Coverage Δ
hive 34.89% <30.61%> (-0.09%) ⬇️
mysql 52.84% <48.97%> (-0.13%) ⬇️
postgres 52.85% <48.97%> (-0.13%) ⬇️
presto 36.64% <30.61%> (-0.09%) ⬇️
python 87.24% <95.91%> (+33.98%) ⬆️
sqlite 52.61% <48.97%> (-0.13%) ⬇️
unit 81.54% <95.91%> (?)

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.

@rusackas

Copy link
Copy Markdown
Member

Good catch on the soft-delete relationship gap, this closes a real import-breaking hole. One thing before this merges though: sadpandajoe's right that all three new tests mock can_access_all_datasources=True, so a regression in the new skip_visibility_filter bypass wouldn't fail anything.

Could you add a case where the caller can't access the dataset and assert the bundle doesn't leak it?

Also curious about codeant's point on the hard-delete test, since the importer still requires dataset_uuid, does that bundle just stay unimportable, or is that an accepted edge case?

…d dataset

The three existing tests run with can_access_all_datasources patched to
True, so a lookup that also skipped the permission filter would still
pass them. Add a chart editor with no grant on the dataset:

- the chart export gives them the chart alone, with no dataset_uuid and
  no datasets/ or databases/ file, with and without export_related;
- the nested dataset export still raises DatasetNotFoundError for them
  when include_deleted lifts the soft-delete filter.

Signed-off-by: L4XB <[email protected]>
@L4XB

L4XB commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@rusackas Both done.

Access. Added in 768bf00: a chart editor with no role and no grant on the dataset, so DatasourceFilter hides it (trash included). The dataset is soft-deleted, and the test asserts the row is still there, so only the missing access keeps it out.

  • test_export_chart_does_not_leak_deleted_dataset_without_access, parametrized over export_related: the bundle holds the chart alone, with no dataset_uuid and no datasets/ or databases/ file.
  • test_nested_dataset_export_keeps_access_filter_for_deleted_dataset: ExportDatasetsCommand([id], include_deleted=True) still raises DatasetNotFoundError for that user. include_deleted lifts the soft-delete filter and nothing else.

To check that they guard the bypass, I widened each lookup to skip the permission filter as well:

mutation result
find_chart_dataset also passes skip_base_filter=True both does_not_leak cases fail. With export_related=False the chart YAML carries the dataset's uuid (assert 'dataset_uuid' not in {…, 'dataset_uuid': 'f91627cb-…'}); with it, the nested export raises. The three original tests still pass.
validate() also passes skip_base_filter=self.include_deleted keeps_access_filter fails; the other 5 pass

The file passes 6/6 as pushed, and ruff and pre-commit's mypy are clean on it.

Hard delete. I measured it. After DatasetDAO.hard_delete, the export contains charts/my_chart_1.yaml, metadata.yaml and tags.yaml, and importing that bundle fails with CommandInvalidError {'charts/my_chart_1.yaml': {'dataset_uuid': ['Missing data for required field.']}}. This PR doesn't change that case: with no row left to resolve, find_chart_dataset returns None exactly where model.table did before.

I'd treat it as accepted for this PR. The chart no longer has any datasource, so the importer can't recreate it, and refusing is correct. The weak part is the message, which doesn't say the dataset is gone. If you want it handled, a follow-up could either have the export skip such a chart with a warning, or have the importer name the chart and the missing dataset. I'd lean towards the importer, since that keeps the chart's params in the bundle.

@bito-code-review

bito-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4808d3

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/commands/chart/export_test.py - 1
    • Over-broad filter skip in assertion · Line 241-243
      This sanity check skips the DAO base (permission) filter, unlike `find_chart_dataset`, which keeps it (`superset/commands/chart/export.py:67`). The comment says only missing access keeps the row out, but with `skip_base_filter=True` the assertion would also pass if the permission filter were the blocker, weakening the stated intent.
Review Details
  • Files reviewed - 1 · Commit Range: 4ae4cc7..768bf00
    • tests/unit_tests/commands/chart/export_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 2, 2026
…port-round-trip

# Conflicts:
#	superset/commands/chart/export.py
@L4XB

L4XB commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged master to resolve the conflict in superset/commands/chart/export.py with #44396 and #43232. No behavior change beyond what was approved:

Checked on the merged tree:

  • tests/unit_tests/commands/chart/export_test.py: 6 passed.
  • tests/unit_tests/{commands,charts,datasets,dashboards,annotation_layers}: 2382 passed. The one failure, sql_lab/test_estimate.py, is a missing psycopg2 in my local env.
  • ruff format --check and ruff check (0.9.7) and mypy --check-untyped-defs (1.15.0, the pre-commit hook's stubs) are clean on the three files.

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Oct 5, 2026
Comment thread superset/commands/chart/export.py Resolved
L4XB added 2 commits October 17, 2026 12:25
… the trash

ExportDashboardsCommand looked up the datasets of native filters and
display controls without the trash, so a filter on a soft-deleted
dataset lost its datasetId without gaining a datasetUuid, and the bundle
did not carry the dataset. Look the datasets up with
skip_visibility_filter and export them with include_deleted, as the
chart export does for a chart's own dataset.

ExportModelsCommand only passes skip_visibility_filter when
include_deleted is set, so other callers keep the plain lookup.
The chart round trip passed even if ImportChartsCommand skipped the
chart, since the original row kept its name and dataset id. Rename the
chart and clear its dataset id before importing, so both have to come
back from the bundle.

Add the dashboard case: a native filter on a soft-deleted dataset keeps
its datasetUuid through export, and import points it at the restored
dataset. The filter is cleared before importing, so it has to come back
from the bundle too.
@codeant-ai-for-open-source

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

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Medium Risk

  • The PR needs attention before merging.
  • The hard-delete case still emits a chart without dataset_uuid; the importer requires that field, so the exported bundle cannot be re-imported.

Assessed commit: 401370416f57

The filter in the round-trip test targeted the chart's own dataset, which
ExportChartsCommand bundles anyway, so the test stayed green with the
trash-inclusive lookup in ExportDashboardsCommand._export reverted. The
filter now targets a second dataset in the trash that no chart on the
dashboard uses, and the mocked dashboard tests check that both lookups
pass skip_visibility_filter=True. Reverting either lookup now fails the
round trip and one mocked test.
Comment thread superset/commands/export/models.py Resolved
Comment thread superset/commands/chart/export.py Resolved
Two behaviours the export fix relies on had no test that would fail
without them. ExportDatasetsCommand keeps a readable dataset in the
trash out unless include_deleted=True, so the dataset export endpoint
and other callers do not start exporting trashed datasets. And
find_chart_dataset looks a dataset up by datasource_id only for a table
chart, so exporting a semantic-view chart with its related assets does
not bundle an unrelated table that has the same numeric id. Dropping the
flag check, or the datasource_type guard, now fails one test each.
Comment thread superset/commands/chart/export.py Resolved
L4XB and others added 2 commits October 17, 2026 16:27
ExportAssetsCommand exports datasets from the visibility-filtered
find_all(), which leaves the trash out, while the chart files now write
dataset_uuid for a dataset in the trash and native filters their
datasetUuid. ImportAssetsCommand looks those up in the bundle, so it
raised a KeyError for the missing dataset instead of the schema error it
gave before.

The assets export now also exports the datasets in the trash that the
exported charts and native filters or display controls name, with the
DAO base filter still applied. The dataset ids a dashboard's filters
target are read by a shared dashboard_dataset_ids() helper.
Comment thread superset/commands/export/assets.py Resolved
Comment thread superset/commands/export/assets.py Resolved
Comment thread superset/commands/export/assets.py Resolved
Review of apache#44347:
- A chart's dataset came from Slice.table, which is loaded without the
  DAO base filter, so a live dataset the user cannot read reached
  ExportDatasetsCommand and failed the whole export. Chart and filter
  ids now share one filtered lookup.
- A dashboard whose json_metadata is null or a list parsed, then raised
  AttributeError and stopped every export. Such metadata names no
  targets.
- dashboard_dataset_ids read a semantic-view target's datasetId as a
  table id, so an unrelated trashed table sharing the number was
  bundled. It now reads table targets only.
@rusackas
rusackas merged commit 77ebc0e into apache:master Oct 21, 2026
72 checks passed
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.

3 participants