{"record":{"id":"7e82c003e06d6124","repo":"apache/superset","slug":"dataset-does-not-exist-7e82c0","errorCode":null,"errorMessage":"Dataset does not exist","messagePattern":"Dataset does not exist","errorType":"exception","errorClass":"DatasetNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/dataset/refresh.py","lineNumber":90,"sourceCode":"                detector = DatetimeFormatDetector()\n                detector.detect_all_formats(self._model)\n                logger.info(\n                    \"Detected datetime formats for dataset %s\", self._model.table_name\n                )\n            except Exception as ex:\n                logger.exception(\n                    \"Failed to detect datetime formats for dataset %s: %s\",\n                    self._model.table_name,\n                    str(ex),\n                )\n\n        return self._model\n\n    def validate(self) -> None:\n        # Validate/populate model exists\n        self._model = DatasetDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise DatasetNotFoundError()\n        # Check editorship\n        try:\n            security_manager.raise_for_editorship(self._model)\n        except SupersetSecurityException as ex:\n            raise DatasetForbiddenError() from ex\n","sourceCodeStart":72,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/refresh.py#L72-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the id exists: GET /api/v1/dataset/{id} — a 404 there confirms the row is gone.","If the dataset was soft-deleted, restore it via the restore endpoint (PUT /api/v1/dataset/{id}/restore or the trash UI) before refreshing.","Re-run your automation against a freshly listed set of ids (GET /api/v1/dataset?q=...) instead of hardcoded values.","Check for environment mismatch: the id you hold may belong to a different Superset instance."],"exampleFix":"# before\nDatasetRefreshCommand(model_id=42).run()  # raises DatasetNotFoundError\n\n# after\nfrom superset.daos.dataset import DatasetDAO\nmodel = DatasetDAO.find_by_id(42)\nif model is None:\n    raise SystemExit(f\"dataset 42 not found; list valid ids first\")\nDatasetRefreshCommand(model_id=42).run()","handlingStrategy":"validation","validationCode":"from superset.daos.dataset import DatasetDAO\n\nif DatasetDAO.find_by_id(model_id) is None:\n    raise LookupError(f\"dataset {model_id} missing; re-enumerate ids\")","typeGuard":null,"tryCatchPattern":"try:\n    DatasetRefreshCommand(model_id=model_id).run()\nexcept DatasetNotFoundError:\n    # drop stale id from your working set; optionally look up by UUID/table name","preventionTips":["Address datasets by UUID in cross-environment automation.","Re-list ids immediately before batch operations.","Distinguish soft-deleted (restorable) from hard-deleted before failing."],"tags":["dataset","not-found","api","id-mismatch"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}