apache/superset · error · DatasetNotFoundError

Dataset does not exist

Error message

Dataset does not exist

What it means

DatasetNotFoundError (HTTP 404, 'Dataset does not exist') is raised by the bulk dataset delete command when DatasetDAO.find_by_ids returns fewer models than requested ids — i.e., at least one id in the DELETE payload does not exist. The command is all-or-nothing: one missing id fails the whole request before any deletion happens.

Source

Thrown at superset/commands/dataset/delete.py:51

logger = logging.getLogger(__name__)


class DeleteDatasetCommand(BaseCommand):
    def __init__(self, model_ids: list[int]):
        self._model_ids = model_ids
        self._models: Optional[list[SqlaTable]] = None

    @transaction(on_error=partial(on_error, reraise=DatasetDeleteFailedError))
    def run(self) -> None:
        self.validate()
        assert self._models
        DatasetDAO.delete(self._models)

    def validate(self) -> None:
        # Validate/populate model exists
        self._models = DatasetDAO.find_by_ids(self._model_ids)
        if not self._models or len(self._models) != len(self._model_ids):
            raise DatasetNotFoundError()
        # Check editorship
        for model in self._models:
            try:
                security_manager.raise_for_editorship(model)
            except SupersetSecurityException as ex:
                raise DatasetForbiddenError() from ex

View on GitHub (pinned to f4587218dd)

Solutions

  1. Resolve which ids are missing (GET /api/v1/dataset/?q=(id:...) or compare against the list endpoint) and retry with only existing ids.
  2. For idempotent cleanup, treat 404 on specific ids as 'already deleted' and continue with the rest.
  3. In scripts, look ids up by uuid or name at runtime instead of persisting integer ids.
Defensive patterns

Strategy: validation

Validate before calling

# Filter the bulk-delete id list down to existing datasets
from superset.daos.dataset import DatasetDAO

def existing_dataset_ids(ids: list[int]) -> list[int]:
    found = {d.id for d in (DatasetDAO.find_by_ids(ids) or [])}
    return [i for i in ids if i in found]

Try / catch

from superset.commands.dataset.exceptions import DatasetNotFoundError
try:
    DeleteDatasetsCommand(ids).run()
except DatasetNotFoundError:
    # all-or-nothing failed: retry with only the ids that still exist
    DeleteDatasetsCommand(existing_dataset_ids(ids)).run()

Prevention

When it happens

Trigger: DELETE /api/v1/dataset/ with body {"q": "(id:1,999)"} where 999 doesn't exist; datasets deleted by another user between selection and bulk delete; ids from a different environment's metadata DB.

Common situations: Bulk-cleaning scripts with hardcoded id lists; UI multi-select over stale data; concurrent deletes by two admins.

Related errors


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