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
- Resolve which ids are missing (GET /api/v1/dataset/?q=(id:...) or compare against the list endpoint) and retry with only existing ids.
- For idempotent cleanup, treat 404 on specific ids as 'already deleted' and continue with the rest.
- 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
- Re-resolve ids immediately before bulk operations; expect concurrent deletes.
- Design bulk flows to shrink the id set on 404 rather than abort the batch.
- Reference datasets by uuid in persisted scripts, resolving ids per run.
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
- Dataset column not found.
- Changing this dataset is forbidden
- The database was not found.
- Annotation not found.
- Annotation layer not found.
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/396fa6bb4c58dc5b.
Report an issue: GitHub.