{"record":{"id":"4734eb68881c00ed","repo":"apache/superset","slug":"dataset-does-not-exist-4734eb","errorCode":null,"errorMessage":"Dataset does not exist","messagePattern":"Dataset does not exist","errorType":"exception","errorClass":"DatasetNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/dataset/update.py","lineNumber":105,"sourceCode":"            catches=(\n                SQLAlchemyError,\n                ValueError,\n            ),\n            reraise=DatasetUpdateFailedError,\n        )\n    )\n    def run(self) -> Model:\n        self.validate()\n        assert self._model\n        return DatasetDAO.update(self._model, attributes=self._properties)\n\n    def validate(self) -> None:\n        exceptions: list[ValidationError] = []\n\n        # Validate/populate model exists\n        self._model = DatasetDAO.find_by_id(self._model_id)\n        if not self._model:\n            raise DatasetNotFoundError()\n\n        # Check permission to update the dataset\n        try:\n            security_manager.raise_for_editorship(self._model)\n        except SupersetSecurityException as ex:\n            raise DatasetForbiddenError() from ex\n\n        # Validate/Populate editors\n        compute_subjects(self._model, self._properties, exceptions)\n\n        self._validate_dataset_source(exceptions)\n        self._validate_semantics(exceptions)\n\n        if exceptions:\n            raise DatasetInvalidError(exceptions=exceptions)\n\n    def _validate_dataset_source(self, exceptions: list[ValidationError]) -> None:\n        # we know we have a valid model","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dataset/update.py#L87-L123","documentation":"DatasetNotFoundError is raised by UpdateDatasetCommand.validate() when DatasetDAO.find_by_id(self._model_id) returns None before any property changes are applied. The update endpoint maps it to HTTP 404.","triggerScenarios":"PUT/PATCH /api/v1/dataset/{id} where id does not exist, was hard-deleted, or is soft-deleted and hidden by DAO filters. Also occurs when a batch update payload contains a stale id.","commonSituations":"Configuration-as-code pipelines (yaml/json exports) applied to an environment where dataset ids differ. Races where another process deletes the dataset between a GET and the PUT. Ids taken from an exported YAML that used a different metadata DB.","solutions":["Verify existence first: GET /api/v1/dataset/{id} (and GET /api/v1/dataset/?q=(id:eq:{id}) for filtered environments).","If soft-deleted, restore the row before updating.","Prefer addressing datasets by UUID in automation instead of integer ids to survive cross-environment drift.","Re-fetch the id list right before bulk updates rather than caching it."],"exampleFix":"# before\nclient.put(f\"/api/v1/dataset/{dataset_id}\", json=props)  # 404\n\n# after\nresp = client.get(f\"/api/v1/dataset/{dataset_id}\")\nif resp.status_code == 404:\n    dataset_id = find_dataset_by_uuid(client, dataset_uuid)\nclient.put(f\"/api/v1/dataset/{dataset_id}\", json=props)","handlingStrategy":"validation","validationCode":"resp = client.get(f\"/api/v1/dataset/{dataset_id}\")\nif resp.status_code == 404:\n    dataset_id = resolve_dataset_by_uuid(client, dataset_uuid)","typeGuard":null,"tryCatchPattern":"try:\n    UpdateDatasetCommand(user, model_id, properties).run()\nexcept DatasetNotFoundError:\n    refresh_id_cache()  # then retry once with the resolved id","preventionTips":["Prefer UUID-keyed lookups over integer ids in pipelines.","GET before PUT in write paths.","Handle delete/create races by re-resolving instead of crashing."],"tags":["dataset","not-found","api","crud"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}