{"record":{"id":"4c9ed795c8ce4ab3","repo":"apache/superset","slug":"semantic-layer-does-not-exist-4c9ed7","errorCode":null,"errorMessage":"Semantic layer does not exist","messagePattern":"Semantic layer does not exist","errorType":"exception","errorClass":"SemanticLayerNotFoundError","httpStatus":404,"severity":"error","filePath":"superset/commands/semantic_layer/delete.py","lineNumber":61,"sourceCode":"        self._uuid = uuid\n        self._model: SemanticLayer | None = None\n\n    @transaction(\n        on_error=partial(\n            on_error,\n            catches=(SQLAlchemyError,),\n            reraise=SemanticLayerDeleteFailedError,\n        )\n    )\n    def run(self) -> None:\n        self.validate()\n        assert self._model\n        SemanticLayerDAO.delete([self._model])\n\n    def validate(self) -> None:\n        self._model = SemanticLayerDAO.find_by_uuid(self._uuid)\n        if not self._model:\n            raise SemanticLayerNotFoundError()\n\n\nclass DeleteSemanticViewCommand(BaseCommand):\n    def __init__(self, pk: int):\n        self._pk = pk\n        self._model: SemanticView | None = None\n\n    @transaction(\n        on_error=partial(\n            on_error,\n            catches=(SQLAlchemyError,),\n            reraise=SemanticViewDeleteFailedError,\n        )\n    )\n    def run(self) -> None:\n        self.validate()\n        assert self._model\n        SemanticViewDAO.delete([self._model])","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/semantic_layer/delete.py#L43-L79","documentation":"Raised by DeleteSemanticLayerCommand.validate() (superset/commands/semantic_layer/delete.py:61) when SemanticLayerDAO.find_by_uuid(self._uuid) returns None. The delete command resolves the semantic layer by its UUID string before deleting; a missing or malformed UUID means there is nothing to delete and the command aborts with SemanticLayerNotFoundError (typically surfaced as HTTP 404).","triggerScenarios":"DELETE on the semantic layer REST endpoint with a UUID that does not exist in the metadata DB; the layer was already deleted by another request; the UUID string is typo'd or truncated when copied from the API response.","commonSituations":"Race between two delete requests, stale frontend state holding an old UUID after someone else removed the layer, or scripts iterating over a cached list of layer UUIDs.","solutions":["Verify the UUID exists first via GET /api/v1/semantic_layer/{uuid} (or SemanticLayerDAO.find_by_uuid) before issuing the delete","Treat 404 on delete as success if the goal is simply 'make it gone' (idempotent delete handling)","Refresh the list of semantic layers in the client before allowing delete actions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from superset.daos.semantic_layer import SemanticLayerDAO\n\nmodel = SemanticLayerDAO.find_by_uuid(layer_uuid)\nif model is None:\n    raise LookupError(f\"semantic layer {layer_uuid} already gone\")","typeGuard":null,"tryCatchPattern":"try:\n    DeleteSemanticLayerCommand(layer_uuid).run()\nexcept SemanticLayerNotFoundError:\n    pass  # idempotent delete: already gone","preventionTips":["Refresh the layer list before offering delete actions in UIs","Treat 404 on delete as success in automation scripts"],"tags":["semantic-layer","not-found","delete","rest-api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}