Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: project name uniqueness constraint should exclude deleted projects (#10668)

Marc Klingen4000507e5722
diff --git a/web/src/ee/features/admin-api/server/projects/createProject.ts b/web/src/ee/features/admin-api/server/projects/createProject.ts
index 9c5654194e..1f485a4dbd 100644
--- a/web/src/ee/features/admin-api/server/projects/createProject.ts
+++ b/web/src/ee/features/admin-api/server/projects/createProject.ts
@@ -64,6 +64,7 @@ export async function handleCreateProject(
where: {
name,
orgId: scope.orgId,
+ deletedAt: null,
},
});
diff --git a/web/src/features/projects/server/projectsRouter.ts b/web/src/features/projects/server/projectsRouter.ts
index e73ef4683e..7e603955d1 100644
--- a/web/src/features/projects/server/projectsRouter.ts
+++ b/web/src/features/projects/server/projectsRouter.ts
@@ -38,6 +38,7 @@ export const projectsRouter = createTRPCRouter({
where: {
name: input.name,
orgId: input.orgId,
+ deletedAt: null,
},
});
@@ -84,6 +85,25 @@ export const projectsRouter = createTRPCRouter({
scope: "project:update",
});
+ // check if the project name is already taken by another project
+ const otherProjectWithSameName = await ctx.prisma.project.findFirst({
+ where: {
+ name: input.newName,
+ orgId: ctx.session.orgId,
+ deletedAt: null,
+ id: {
+ not: input.projectId,
+ },
+ },
+ });
+ if (otherProjectWithSameName) {
+ throw new TRPCError({
+ code: "CONFLICT",
+ message:
+ "A project with this name already exists in your organization",
+ });
+ }
+
const project = await ctx.prisma.project.update({
where: {
id: input.projectId,