{"record":{"id":"6aac58621556d5c9","repo":"mlflow/mlflow","slug":"resource-already-exists-6aac58","errorCode":"RESOURCE_ALREADY_EXISTS","errorMessage":"Workspace '{workspace.name}' already exists.","messagePattern":"Workspace '(.+?)' already exists\\.","errorType":"error_code","errorClass":"MlflowException","httpStatus":409,"severity":"error","filePath":"mlflow/store/workspace/rest_store.py","lineNumber":88,"sourceCode":"        if workspace.default_artifact_root is not None:\n            request_message.default_artifact_root = workspace.default_artifact_root\n        if workspace.trace_archival_location is not None:\n            request_message.trace_archival_config.location = workspace.trace_archival_location\n        if workspace.trace_archival_retention is not None:\n            request_message.trace_archival_config.retention = workspace.trace_archival_retention\n        try:\n            proto = call_endpoint(\n                host_creds=self.get_host_creds(),\n                endpoint=WORKSPACES_ENDPOINT,\n                method=\"POST\",\n                json_body=message_to_json(request_message),\n                response_proto=CreateWorkspace.Response(),\n                expected_status=201,\n            )\n        except RestException as exc:\n            if exc.error_code == databricks_pb2.ErrorCode.Name(RESOURCE_ALREADY_EXISTS):\n                message = exc.message or f\"Workspace '{workspace.name}' already exists.\"\n                raise MlflowException(message, RESOURCE_ALREADY_EXISTS) from exc\n            raise\n\n        return self._workspace_from_proto(proto)\n\n    def update_workspace(self, workspace: Workspace) -> Workspace:\n        request_message = UpdateWorkspace()\n        if workspace.description is not None:\n            request_message.description = workspace.description\n        if workspace.default_artifact_root is not None:\n            request_message.default_artifact_root = workspace.default_artifact_root\n        if workspace.trace_archival_location is not None:\n            request_message.trace_archival_config.location = workspace.trace_archival_location\n        if workspace.trace_archival_retention is not None:\n            request_message.trace_archival_config.retention = workspace.trace_archival_retention\n        proto = call_endpoint(\n            host_creds=self.get_host_creds(),\n            endpoint=f\"{WORKSPACES_ENDPOINT}/{_quote_workspace(workspace.name)}\",\n            method=\"PATCH\",","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/workspace/rest_store.py#L70-L106","documentation":"RestWorkspaceStore.create_workspace expects HTTP 201; when the server answers with RESOURCE_ALREADY_EXISTS, the client re-raises it as an MlflowException with code RESOURCE_ALREADY_EXISTS, preserving the server's message when present. It means a workspace with the same name already exists on the server.","triggerScenarios":"POSTing a CreateWorkspace request for a name that is already registered on the tracking server; concurrent creation races where two processes create the same workspace name.","commonSituations":"Re-running idempotency-broken setup scripts that create workspaces; CI provisioning colliding with an existing workspace; teams sharing a server and independently creating the same workspace name.","solutions":["Call list_workspaces or get_workspace first and skip creation if the name already exists","Catch MlflowException with error_code RESOURCE_ALREADY_EXISTS and treat it as a no-op if creation is meant to be idempotent","Use a unique workspace name (e.g. with a team/env suffix) to avoid collisions"],"exampleFix":"// before\ncreate_workspace(Workspace(name=\"team-a\"))  # raises if exists\n// after\ntry:\n    create_workspace(Workspace(name=\"team-a\"))\nexcept MlflowException as e:\n    if e.error_code != \"RESOURCE_ALREADY_EXISTS\":\n        raise","handlingStrategy":"try-catch","validationCode":"existing = {w.name for w in store.list_workspaces()}\nif name in existing:\n    skip_creation = True","typeGuard":null,"tryCatchPattern":"try:\n    ws = store.create_workspace(Workspace(name=name))\nexcept MlflowException as e:\n    if e.error_code == \"RESOURCE_ALREADY_EXISTS\":\n        ws = store.get_workspace(name)  # treat as idempotent\n    else:\n        raise","preventionTips":["Make provisioning scripts idempotent by checking existence first","Use get-before-create in CI/CD workspace setup","Adopt unique naming conventions per team/environment"],"tags":["rest","workspace","conflict","duplicate"],"backgroundTag":"resource-already-exists","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}