apache/superset · error · ImportFailedError

Dataset {existing.table_name!r} (uuid {config['uuid']}) alre

Error message

Dataset {existing.table_name!r} (uuid {config['uuid']}) already exists and user doesn't have permissions to restore it

What it means

On the restore path of dataset import (soft-deleted UUID match with can_write), if the current user is set and is neither an editor of the existing dataset nor an admin, ImportFailedError is raised. It prevents a privileged-enough-to-write user from restoring (and modifying) a dataset they do not own or co-edit.

Source

Thrown at superset/commands/dataset/importers/v1/utils.py:274

            if not can_write:
                # Case B: don't silently return a soft-deleted row to a caller
                # without write permission — that would let the importer
                # reattach charts/dashboards to a deleted dataset and produce
                # broken charts.
                raise ImportFailedError(
                    f"Dataset {existing.table_name!r} (uuid {config['uuid']}) "
                    "was deleted and re-import requires can_write permission "
                    "to restore it"
                )
            # ``user`` is None on background / example-loader paths; combined
            # with ``can_write`` (typically from ``ignore_permissions=True``)
            # the editorship check is intentionally skipped because the caller
            # already established trust.
            if user and (
                not security_manager.is_editor(existing)
                and not security_manager.is_admin()
            ):
                raise ImportFailedError(
                    f"Dataset {existing.table_name!r} (uuid {config['uuid']}) "
                    "already exists and user doesn't have permissions to "
                    "restore it"
                )
            # Before clearing ``deleted_at``, refuse if another active dataset
            # already references the same physical table. Otherwise the
            # restore would produce two live ``SqlaTable`` rows for one
            # physical table, breaking the logical-uniqueness contract. The
            # shared DAO helper relies on the SoftDeleteMixin listener to
            # consider only active rows, excludes ``existing`` itself via
            # ``id !=``, and normalizes the catalog the same way create/update
            # uniqueness does.
            # Probe the POST-update identity: the uploaded config may rename
            # table_name/schema/catalog, and the collision that matters is
            # against the identity the restored row will end up with — not
            # the stale stored one. Absent keys fall back to the stored
            # values; explicit nulls are respected.
            incoming_identity = Table(

View on GitHub (pinned to f4587218dd)

Solutions

  1. Add the importing user as an owner/editor of the soft-deleted dataset first (admin action), then retry the import
  2. Perform the import as an admin
  3. Have an admin restore the dataset via the REST delete-restore endpoint instead of re-import
Defensive patterns

Strategy: try-catch

Validate before calling

from superset import security_manager
# before restoring via import, confirm editorship
existing = find_existing_for_import(SqlaTable, config['uuid'])
if existing is not None and existing.deleted_at is not None:
    user = security_manager.get_current_user()
    if user and not (security_manager.is_editor(existing) or security_manager.is_admin()):
        raise PermissionError('ask an owner/admin to perform this import')

Try / catch

from superset.commands.exceptions import ImportFailedError
try:
    import_dataset(config, overwrite=True)
except ImportFailedError as ex:
    if "doesn't have permissions to restore it" in str(ex):
        # request ownership on the soft-deleted dataset or import as admin
        ...

Prevention

When it happens

Trigger: A user with can_write imports a bundle matching a soft-deleted dataset that was owned by someone else, with no editorship (owner) grant to this user, and user context present (not a background job).

Common situations: Team A deletes a dataset; team B tries to re-import the same export to restore it; ownership was never transferred so B is not an editor.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/f02fad3ec3c941d2. Report an issue: GitHub.