{"record":{"id":"7d0d225f02df0321","repo":"glzr-io/glazewm","slug":"the-workspace-already-exists","errorCode":null,"errorMessage":"The workspace \"{}\" already exists","messagePattern":"The workspace \"(.+?)\" already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/wm/src/commands/workspace/update_workspace_config.rs","lineNumber":22,"sourceCode":"use super::sort_workspaces;\r\nuse crate::{\r\n  models::Workspace, traits::CommonGetters, user_config::UserConfig,\r\n  wm_state::WmState,\r\n};\r\n\r\npub fn update_workspace_config(\r\n  workspace: &Workspace,\r\n  state: &WmState,\r\n  config: &UserConfig,\r\n  new_config: &InvokeUpdateWorkspaceConfig,\r\n) -> anyhow::Result<()> {\r\n  let current_config = workspace.config();\r\n\r\n  // Validate the workspace name change.\r\n  if let Some(new_name) = &new_config.name {\r\n    if new_name != &current_config.name {\r\n      if let Some(_other_workspace) = state.workspace_by_name(new_name) {\r\n        anyhow::bail!(\"The workspace \\\"{}\\\" already exists\", new_name);\r\n      }\r\n    }\r\n  }\r\n\r\n  // Update the config with the incoming values.\r\n  let updated_config = WorkspaceConfig {\r\n    name: new_config\r\n      .name\r\n      .clone()\r\n      .unwrap_or(current_config.name.clone()),\r\n    display_name: new_config\r\n      .display_name\r\n      .clone()\r\n      .or(current_config.display_name.clone()),\r\n    bind_to_monitor: new_config\r\n      .bind_to_monitor\r\n      .or(current_config.bind_to_monitor),\r\n    keep_alive: new_config.keep_alive.unwrap_or(current_config.keep_alive),\r","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/glzr-io/glazewm/blob/5709ad0a3c7c386bbc3e38166a865ffc12937515/packages/wm/src/commands/workspace/update_workspace_config.rs#L4-L40","documentation":"`update_workspace_config` validates a workspace rename before applying it. If the requested new name matches another existing workspace, the rename would create a duplicate, so it bails with the conflicting name in the message.","triggerScenarios":"Calling `update_workspace_config` (directly or via a workspace-focused IPC command like `wm command focused_workspace ...` or config reload) with `new_config.name` equal to the name of a different workspace.","commonSituations":"Duplicated workspace names in the user config after editing, or IPC automation renaming a workspace to a name already in use.","solutions":["Pick a unique workspace name before renaming","List existing workspaces and check the target name is free first","Handle the error in IPC clients and surface a clear message to the user"],"exampleFix":"// before\nupdate_workspace_config(&state, &workspace, WorkspaceConfig { name: Some(\"1\".into()), ..cfg })?;\n// after\nif state.workspace_by_name(\"1\").is_none() {\n  update_workspace_config(&state, &workspace, WorkspaceConfig { name: Some(\"1\".into()), ..cfg })?;\n}","handlingStrategy":"validation","validationCode":"if let Some(_) = state.workspace_by_name(&new_name) {\n  eprintln!(\"workspace name '{new_name}' is already in use\");\n} else {\n  update_workspace_config(&state, &workspace, new_config)?;\n}","typeGuard":null,"tryCatchPattern":"match update_workspace_config(&state, &workspace, new_config) {\n  Err(e) if e.to_string().contains(\"already exists\") => {\n    eprintln!(\"choose a different workspace name\");\n  }\n  r => r?,\n}","preventionTips":["Check workspace_by_name before any rename","Enforce unique workspace names in generated configs","Surface name-conflict errors to end users in IPC clients"],"tags":["workspace","config","naming"],"backgroundTag":"conflicting-config-options","analyzedSha":"5709ad0a3c7c386bbc3e38166a865ffc12937515","analyzedAt":"2026-09-08T03:26:40.288Z","contentChangedAt":"2026-09-08T03:26:40.288Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}