apache/superset · error · SemanticLayerInvalidError

Name already exists: {name}

Error message

Name already exists: {name}

What it means

Raised by UpdateSemanticLayerCommand.validate() (superset/commands/semantic_layer/update.py:121) as SemanticLayerInvalidError when the request includes a non-empty 'name' and SemanticLayerDAO.validate_update_uniqueness(self._uuid, name) returns false. Semantic layer names are globally unique (scoped to the layer's own UUID so unchanged names pass); renaming a layer to an existing name is rejected.

Source

Thrown at superset/commands/semantic_layer/update.py:121

        )
    )
    def run(self) -> Model:
        self.validate()
        assert self._model
        if isinstance(self._properties.get("configuration"), dict):
            self._properties["configuration"] = json.dumps(
                self._properties["configuration"]
            )
        return SemanticLayerDAO.update(self._model, attributes=self._properties)

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

        name = self._properties.get("name")
        if name and not SemanticLayerDAO.validate_update_uniqueness(self._uuid, name):
            raise SemanticLayerInvalidError(f"Name already exists: {name}")

        if configuration := self._properties.get("configuration"):
            sl_type = self._model.type
            cls = registry[sl_type]
            cls.from_configuration(configuration)

View on GitHub (pinned to f4587218dd)

Solutions

  1. List existing semantic layers and pick an unused name before the rename
  2. Delete or rename the conflicting layer first if the goal is to reclaim the name
  3. Suffix names (e.g. '-v2') when intentionally duplicating setups
Defensive patterns

Strategy: validation

Validate before calling

from superset.daos.semantic_layer import SemanticLayerDAO

if name and not SemanticLayerDAO.validate_update_uniqueness(layer_uuid, name):
    raise ValueError(f"layer name '{name}' already taken")

Try / catch

try:
    UpdateSemanticLayerCommand(uuid, {"name": new_name}).run()
except SemanticLayerInvalidError as ex:
    if "already exists" in str(ex):
        # choose another name and resubmit
        

Prevention

When it happens

Trigger: PATCHing a semantic layer with {"name": X} where another layer already has name X; importing/migrating layers that collide on name.

Common situations: Renaming to a display name already used by a teammate's layer, or restoring a layer from a backup while the original still exists.

Related errors


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