apache/superset · error · DatasetNotFoundError

Dataset does not exist

Error message

Dataset does not exist

What it means

DatasetNotFoundError is raised by DatasetRefreshCommand.validate() when DatasetDAO.find_by_id(self._model_id) returns nothing. It means no dataset row with that primary key exists (or is filtered out by DAO visibility rules). It surfaces as an HTTP 404 from the dataset refresh endpoint.

Source

Thrown at superset/commands/dataset/refresh.py:90

                detector = DatetimeFormatDetector()
                detector.detect_all_formats(self._model)
                logger.info(
                    "Detected datetime formats for dataset %s", self._model.table_name
                )
            except Exception as ex:
                logger.exception(
                    "Failed to detect datetime formats for dataset %s: %s",
                    self._model.table_name,
                    str(ex),
                )

        return self._model

    def validate(self) -> None:
        # Validate/populate model exists
        self._model = DatasetDAO.find_by_id(self._model_id)
        if not self._model:
            raise DatasetNotFoundError()
        # Check editorship
        try:
            security_manager.raise_for_editorship(self._model)
        except SupersetSecurityException as ex:
            raise DatasetForbiddenError() from ex

View on GitHub (pinned to f4587218dd)

Solutions

  1. Confirm the id exists: GET /api/v1/dataset/{id} — a 404 there confirms the row is gone.
  2. If the dataset was soft-deleted, restore it via the restore endpoint (PUT /api/v1/dataset/{id}/restore or the trash UI) before refreshing.
  3. Re-run your automation against a freshly listed set of ids (GET /api/v1/dataset?q=...) instead of hardcoded values.
  4. Check for environment mismatch: the id you hold may belong to a different Superset instance.

Example fix

# before
DatasetRefreshCommand(model_id=42).run()  # raises DatasetNotFoundError

# after
from superset.daos.dataset import DatasetDAO
model = DatasetDAO.find_by_id(42)
if model is None:
    raise SystemExit(f"dataset 42 not found; list valid ids first")
DatasetRefreshCommand(model_id=42).run()
Defensive patterns

Strategy: validation

Validate before calling

from superset.daos.dataset import DatasetDAO

if DatasetDAO.find_by_id(model_id) is None:
    raise LookupError(f"dataset {model_id} missing; re-enumerate ids")

Try / catch

try:
    DatasetRefreshCommand(model_id=model_id).run()
except DatasetNotFoundError:
    # drop stale id from your working set; optionally look up by UUID/table name

Prevention

When it happens

Trigger: Calling the dataset refresh endpoint (e.g. PUT/POST /api/v1/dataset/{id}/refresh, or Dropdown refresh in the UI) with an id that does not exist, was hard-deleted, or is a soft-deleted row excluded from the default query filters.

Common situations: Stale bookmarked/UI URL after a dataset was deleted and recreated with a new id. Scripts iterating over ids exported from another environment (dev vs prod id drift). Soft-deleted datasets that find_by_id skips due to visibility filters after enabling the soft-delete feature.

Related errors


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