apache/superset · error · ImportFailedError

Dataset doesn't exist and user doesn't have permission to cr

Error message

Dataset doesn't exist and user doesn't have permission to create datasets

What it means

When the imported dataset's UUID matches nothing existing and the caller lacks can_write, import_dataset raises ImportFailedError('Dataset doesn't exist and user doesn't have permission to create datasets'). Creation via import requires the same write permission as the REST create path.

Source

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

            overwrite_identity = Table(
                config.get("table_name") or existing.table_name,
                config.get("schema", existing.schema),
                config.get("catalog", existing.catalog),
            )
            if not DatasetDAO.validate_update_uniqueness(
                existing.database, overwrite_identity, dataset_id=existing.id
            ):
                raise ImportFailedError(
                    f"Dataset {existing.table_name!r} (uuid {config['uuid']}) "
                    "cannot be overwritten: another dataset (possibly "
                    "soft-deleted) already references the target table "
                    f"({overwrite_identity.table!r}). Restore or rename the "
                    "other dataset, or change this upload's table name."
                )
            config["id"] = existing.id

    elif not can_write:
        raise ImportFailedError(
            "Dataset doesn't exist and user doesn't have permission to create datasets"
        )
    else:
        # Creating a brand-new dataset (no UUID match). A soft-deleted dataset
        # may still claim this physical table; ``import_from_dict`` cannot see it
        # (the visibility filter hides soft-deleted rows), so without this guard
        # the import would create an active twin of a hidden dataset. The REST
        # create path blocks the same collision via ``validate_uniqueness`` —
        # mirror it here and direct the user to restore the existing dataset
        # instead of leaving two rows for one physical table.
        database = (
            db.session.query(Database).filter_by(id=config["database_id"]).first()
        )
        if database is not None and (
            soft_twin := DatasetDAO.find_soft_deleted_logical_duplicate(
                database,
                Table(
                    config["table_name"], config.get("schema"), config.get("catalog")

View on GitHub (pinned to f4587218dd)

Solutions

  1. Grant the role the can_write dataset permission (Dataset 'can_create'/write capability) and retry
  2. Import only bundles whose datasets already exist (or drop the new dataset files)
  3. Run the import as a user/role with dataset create rights
Defensive patterns

Strategy: try-catch

Validate before calling

from superset import security_manager
# pre-flight: does the caller have dataset write/create rights?
if not security_manager.can_access('can_write', 'Dataset'):
    raise PermissionError('new-dataset imports require dataset can_write')

Try / catch

from superset.commands.exceptions import ImportFailedError
try:
    import_dataset(config)
except ImportFailedError as ex:
    if "doesn't have permission to create datasets" in str(ex):
        # run under a role with can_write, or strip new datasets from the bundle
        ...

Prevention

When it happens

Trigger: Importing a bundle with brand-new dataset UUIDs under a role without the can_write dataset permission (ignore_permissions false, i.e. a normal user REST import).

Common situations: Viewer/Gamma-style roles attempting imports; import bundles for dashboards that include new datasets being loaded by analysts without create rights.

Related errors


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