apache/superset · error · SemanticViewNotFoundError

Semantic view does not exist

Error message

Semantic view does not exist

What it means

Raised by DeleteSemanticViewCommand.validate() (superset/commands/semantic_layer/delete.py:84) when SemanticViewDAO.find_by_id(self._pk, id_column="id") returns None. The single-view delete looks the view up by integer primary key; if no row matches, SemanticViewNotFoundError is raised before any authorization or deletion happens.

Source

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

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

    def validate(self) -> None:
        self._model = SemanticViewDAO.find_by_id(self._pk, id_column="id")
        if not self._model:
            raise SemanticViewNotFoundError()
        try:
            security_manager.raise_for_editorship(self._model)
        except SupersetSecurityException as ex:
            raise SemanticViewForbiddenError() from ex


class BulkDeleteSemanticViewCommand(BaseCommand):
    def __init__(self, model_ids: list[int]):
        self._model_ids = model_ids
        self._models: list[SemanticView] = []

    @transaction(
        on_error=partial(
            on_error,
            catches=(SQLAlchemyError,),
            reraise=SemanticViewDeleteFailedError,
        )
    )

View on GitHub (pinned to f4587218dd)

Solutions

  1. Confirm the id exists via the list/detail API before deleting
  2. Handle 404 as idempotent success when the end goal is removal
  3. Make sure you pass the integer 'id' field, not the view's 'uuid', to the delete endpoint
Defensive patterns

Strategy: validation

Validate before calling

from superset.daos.semantic_layer import SemanticViewDAO

if SemanticViewDAO.find_by_id(view_id, id_column="id") is None:
    raise LookupError(f"view {view_id} already gone")

Try / catch

try:
    DeleteSemanticViewCommand(view_id).run()
except SemanticViewNotFoundError:
    pass  # already deleted; treat as success

Prevention

When it happens

Trigger: DELETE on the semantic view endpoint with an integer id that does not exist; the view was removed by a concurrent request between the client loading the list and issuing the delete.

Common situations: Stale UI grid after another user deleted the view, replaying an old request, or passing a UUID where the integer id is expected.

Related errors


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