apache/superset · error · SemanticLayerNotFoundError

Semantic layer does not exist

Error message

Semantic layer does not exist

What it means

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).

Source

Thrown at superset/commands/semantic_layer/delete.py:61

        self._uuid = uuid
        self._model: SemanticLayer | None = None

    @transaction(
        on_error=partial(
            on_error,
            catches=(SQLAlchemyError,),
            reraise=SemanticLayerDeleteFailedError,
        )
    )
    def run(self) -> None:
        self.validate()
        assert self._model
        SemanticLayerDAO.delete([self._model])

    def validate(self) -> None:
        self._model = SemanticLayerDAO.find_by_uuid(self._uuid)
        if not self._model:
            raise SemanticLayerNotFoundError()


class DeleteSemanticViewCommand(BaseCommand):
    def __init__(self, pk: int):
        self._pk = pk
        self._model: SemanticView | None = None

    @transaction(
        on_error=partial(
            on_error,
            catches=(SQLAlchemyError,),
            reraise=SemanticViewDeleteFailedError,
        )
    )
    def run(self) -> None:
        self.validate()
        assert self._model
        SemanticViewDAO.delete([self._model])

View on GitHub (pinned to f4587218dd)

Solutions

  1. Verify the UUID exists first via GET /api/v1/semantic_layer/{uuid} (or SemanticLayerDAO.find_by_uuid) before issuing the delete
  2. Treat 404 on delete as success if the goal is simply 'make it gone' (idempotent delete handling)
  3. Refresh the list of semantic layers in the client before allowing delete actions
Defensive patterns

Strategy: validation

Validate before calling

from superset.daos.semantic_layer import SemanticLayerDAO

model = SemanticLayerDAO.find_by_uuid(layer_uuid)
if model is None:
    raise LookupError(f"semantic layer {layer_uuid} already gone")

Try / catch

try:
    DeleteSemanticLayerCommand(layer_uuid).run()
except SemanticLayerNotFoundError:
    pass  # idempotent delete: already gone

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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