{"record":{"id":"416fa87a905ee3c2","repo":"windmill-labs/windmill","slug":"backend-constraint-violation-workspace-remote","errorCode":null,"errorMessage":"Backend constraint violation: (${workspace.remote}, ${workspace.workspaceId}) already exists as \"${backendConflict.name}\". Use --force to overwrite.","messagePattern":"Backend constraint violation: \\((.+?), (.+?)\\) already exists as \"(.+?)\"\\. Use --force to overwrite\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/workspace.ts","lineNumber":392,"sourceCode":"          return false;\n        }\n      }\n    }\n  }\n\n  // Check 2: Same (remote, workspaceId) already exists with a different name\n  const backendConflict = existingWorkspaces.find(\n    (w) =>\n      w.remote === workspace.remote &&\n      w.workspaceId === workspace.workspaceId &&\n      w.name !== workspace.name\n  );\n  if (backendConflict) {\n    if (opts.force) {\n      // Remove the conflicting workspace before adding the new one\n      await removeWorkspace(backendConflict.name, true, opts);\n    } else {\n      throw new Error(\n        `Backend constraint violation: (${workspace.remote}, ${workspace.workspaceId}) already exists as \"${backendConflict.name}\". Use --force to overwrite.`\n      );\n    }\n  }\n\n  // Remove existing workspace with same name (if updating)\n  await removeWorkspace(workspace.name, true, opts);\n\n  // Add the new workspace\n  const filePath = await getWorkspaceConfigFilePath(opts.configDir);\n  const fh = await fsOpen(filePath, \"a\");\n  await fh.write(JSON.stringify(workspace) + \"\\n\");\n  await fh.close();\n  return true;\n}\n\nexport async function removeWorkspace(\n  name: string,","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/workspace.ts#L374-L410","documentation":"The local wmill.yaml already maps this (remote, workspaceId) pair under a different name; adding the same pair under a new name would violate the one-entry-per-workspace invariant the config file maintains, so it throws unless --force removes the old entry first.","triggerScenarios":"Thrown at cli/src/commands/workspace/workspace.ts:392 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the existing workspace name instead of adding a duplicate.","Rerun with --force to replace the old entry with the new name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}