{"record":{"id":"9b6239de6a746dab","repo":"windmill-labs/windmill","slug":"item-already-exists-in-the-target-workspace","errorCode":null,"errorMessage":"item already exists in the target workspace","messagePattern":"item already exists in the target workspace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/utils_workspace_deploy.ts","lineNumber":210,"sourceCode":"function makeProvider(\n\tonBehalfOfPrincipal?: string,\n\tappIdentity?: AppIdentity,\n\t/**\n\t * Refuse the writes the shared `deployItem` reaches for only when the item already exists in\n\t * the target, turning its silent switch to an update into a failure the caller can act on.\n\t * The three below are exactly its `alreadyExists` branches: a flow and an app are replaced\n\t * outright, and a script is given the target's head as `parent_hash`, which is what makes an\n\t * otherwise identical `createScript` an update.\n\t */\n\tconflict?: DeployConflict\n): DeployProvider {\n\tconst withPermissionedAs = <T extends Record<string, any>>(requestBody: T): T => ({\n\t\t...requestBody,\n\t\ton_behalf_of: onBehalfOfPrincipal\n\t})\n\tconst refuseUpdate = (): never => {\n\t\tif (conflict) conflict.hit = true\n\t\tthrow new Error('item already exists in the target workspace')\n\t}\n\treturn {\n\t\texistsFlowByPath: (p) => FlowService.existsFlowByPath(p),\n\t\texistsScriptByPath: (p) => ScriptService.existsScriptByPath(p),\n\t\texistsApp: (p) => AppService.existsApp(p),\n\t\texistsVariable: (p) => VariableService.existsVariable(p),\n\t\texistsResource: (p) => ResourceService.existsResource(p),\n\t\texistsResourceType: (p) => ResourceService.existsResourceType(p),\n\t\texistsFolder: (p) => FolderService.existsFolder(p),\n\t\tgetFlowByPath: (p) => FlowService.getFlowByPath(p),\n\t\tcreateFlow: (p) =>\n\t\t\tFlowService.createFlow({ ...p, requestBody: withPermissionedAs(p.requestBody) }),\n\t\tupdateFlow: (p) =>\n\t\t\tconflict\n\t\t\t\t? refuseUpdate()\n\t\t\t\t: FlowService.updateFlow({ ...p, requestBody: withPermissionedAs(p.requestBody) }),\n\t\tarchiveFlowByPath: (p) => FlowService.archiveFlowByPath(p),\n\t\tgetScriptByPath: (p) => ScriptService.getScriptByPath(p),","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/utils_workspace_deploy.ts#L192-L228","documentation":"Thrown during a Windmill workspace deploy when the item (flow, script, app, or variable) being deployed already exists at that path in the target workspace and the deploy was invoked in a mode that refuses to overwrite existing items. The provider wraps exists* checks and, when a conflict is detected, sets a conflict flag and refuses the update.","triggerScenarios":"Deploying via utils_workspace_deploy.ts while the target path already holds an item of the same kind in the destination workspace, and the deploy options disallow overwriting (conflict policy).","commonSituations":"Re-running a deploy without a 'sync'/'overwrite' option; deploying to a workspace that already received an earlier deploy of the same paths; path collisions between two items that were renamed upstream.","solutions":["Enable the deploy option that allows overwriting/syncing existing items (the caller decides via the conflict flag) instead of refusing updates","Use a different path for the new item","Delete or rename the existing item at that path in the target workspace before redeploying","Inspect the conflict flag in makeProvider's returned object to identify which path collided"],"exampleFix":"// before\nawait deployWorkspace({ workspaces: ['target'], overwrite: false })\n// after\nawait deployWorkspace({ workspaces: ['target'], overwrite: true })","handlingStrategy":"validation","validationCode":"const exists = await FlowService.existsFlowByPath({ workspace, path });\nif (exists && !allowOverwrite) {\n  throw new Error(`Path already exists in target workspace: ${path}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deployItem(item)\n} catch (e) {\n  if (e.message === 'item already exists in the target workspace') {\n    // redeploy with overwrite enabled or skip this path\n  } else throw e\n}","preventionTips":["Check exists* APIs for every path before deploying","Adopt a consistent sync/overwrite policy for deploy runs","Namespace paths per environment to avoid cross-workspace collisions"],"tags":["deploy","workspace","conflict","duplicate-path"],"backgroundTag":"resource-already-exists","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}