{"record":{"id":"46d5590c589dafce","repo":"apache/superset","slug":"semantic-view-name-already-exists-for-this-lay","errorCode":null,"errorMessage":"Semantic view '{name}' already exists for this layer and configuration","messagePattern":"Semantic view '(.+?)' already exists for this layer and configuration","errorType":"exception","errorClass":"ValueError","httpStatus":500,"severity":"error","filePath":"superset/commands/semantic_layer/create.py","lineNumber":101,"sourceCode":"        )\n    )\n    def run(self) -> Model:\n        self.validate()\n        if isinstance(self._properties.get(\"configuration\"), dict):\n            self._properties[\"configuration\"] = json.dumps(\n                self._properties[\"configuration\"]\n            )\n        return SemanticViewDAO.create(attributes=self._properties)\n\n    def validate(self) -> None:\n        layer_uuid: str = self._properties.get(\"semantic_layer_uuid\", \"\")\n        if not SemanticLayerDAO.find_by_uuid(layer_uuid):\n            raise SemanticLayerNotFoundError()\n\n        name: str = self._properties.get(\"name\", \"\")\n        configuration: dict[str, Any] = self._properties.get(\"configuration\") or {}\n        if not SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration):\n            raise ValueError(\n                f\"Semantic view '{name}' already exists for this layer\"\n                \" and configuration\"\n            )\n","sourceCodeStart":83,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/semantic_layer/create.py#L83-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nCreateSemanticViewCommand({\n    \"semantic_layer_uuid\": layer_uuid,\n    \"name\": \"my_view\",\n    \"configuration\": config,\n}).run()\n\n# after\nfrom superset.semantic_layer.commands import CreateSemanticViewCommand  # noqa\ntry:\n    CreateSemanticViewCommand({\n        \"semantic_layer_uuid\": layer_uuid,\n        \"name\": \"my_view\",\n        \"configuration\": config,\n    }).run()\nexcept ValueError:\n    # view with same name+configuration already exists; update instead\n    pass","handlingStrategy":"validation","validationCode":"from superset.daos.semantic_layer import SemanticViewDAO\n\nexisting = SemanticViewDAO.find_by_uuid(view_uuid) if view_uuid else None\n# or check by name+layer before create:\n# SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration) -> bool\nif not SemanticViewDAO.validate_uniqueness(name, layer_uuid, configuration):\n    raise DuplicateViewError(name)","typeGuard":null,"tryCatchPattern":"try:\n    CreateSemanticViewCommand(properties).run()\nexcept ValueError as ex:\n    if \"already exists\" in str(ex):\n        # fetch the existing view and update instead\n        ...\n    raise","preventionTips":["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"],"tags":["semantic-layer","uniqueness","validation","rest-api"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}