apache/superset · error · ValueError
Semantic view '{name}' already exists for this layer and con
Error message
Semantic view '{name}' already exists for this layer and configuration What it means
Raised by CreateSemanticViewCommand.validate() (superset/commands/semantic_layer/create.py:101) as a plain ValueError when SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration) returns false. Superset enforces that a semantic view's name+configuration pair is unique within a semantic layer (identified by semantic_layer_uuid), so creating a duplicate is rejected before the DAO insert. The API layer translates this into a 4xx response for the POST semantic-view endpoint.
Source
Thrown at superset/commands/semantic_layer/create.py:101
)
)
def run(self) -> Model:
self.validate()
if isinstance(self._properties.get("configuration"), dict):
self._properties["configuration"] = json.dumps(
self._properties["configuration"]
)
return SemanticViewDAO.create(attributes=self._properties)
def validate(self) -> None:
layer_uuid: str = self._properties.get("semantic_layer_uuid", "")
if not SemanticLayerDAO.find_by_uuid(layer_uuid):
raise SemanticLayerNotFoundError()
name: str = self._properties.get("name", "")
configuration: dict[str, Any] = self._properties.get("configuration") or {}
if not SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration):
raise ValueError(
f"Semantic view '{name}' already exists for this layer"
" and configuration"
)
View on GitHub (pinned to f4587218dd)
Solutions
- Check for an existing view first via SemanticViewDAO / the GET semantic-view endpoint using the same name and layer UUID before creating
- If the intent was to modify an existing view, use the update command (UpdateSemanticViewCommand) instead of create
- Change either the view name or its configuration so the pair is unique within the layer
- Make client requests idempotent (disable submit button after first click, deduplicate retries) to avoid accidental duplicates
Example fix
# before
CreateSemanticViewCommand({
"semantic_layer_uuid": layer_uuid,
"name": "my_view",
"configuration": config,
}).run()
# after
from superset.semantic_layer.commands import CreateSemanticViewCommand # noqa
try:
CreateSemanticViewCommand({
"semantic_layer_uuid": layer_uuid,
"name": "my_view",
"configuration": config,
}).run()
except ValueError:
# view with same name+configuration already exists; update instead
pass Defensive patterns
Strategy: validation
Validate before calling
from superset.daos.semantic_layer import SemanticViewDAO
existing = SemanticViewDAO.find_by_uuid(view_uuid) if view_uuid else None
# or check by name+layer before create:
# SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration) -> bool
if not SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration):
raise DuplicateViewError(name) Try / catch
try:
CreateSemanticViewCommand(properties).run()
except ValueError as ex:
if "already exists" in str(ex):
# fetch the existing view and update instead
...
raise Prevention
- Make create requests idempotent: disable double-submits and dedupe retries
- On retry after a timeout, GET the collection first to see if the first attempt succeeded
- Keep view names unique per semantic layer by convention
When it happens
Trigger: POST to the semantic view API with a 'name' and 'configuration' that exactly match an existing view under the same semantic_layer_uuid; the request body omits or reuses a name while resububmitting an unchanged configuration dict.
Common situations: Double-submitting a create form (duplicate HTTP request), retrying a create after a network error when the first attempt actually succeeded, or scripted/test setup that recreates fixture views without cleaning them up first.
Related errors
- A semantic view with name '{name}' and the same configuratio
- Name already exists: {name}
- Unsupported whisker type: ${whiskerOptions}
- Found invalid orderby options
- Unknown Error
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/46d5590c589dafce.
Report an issue: GitHub.