Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(project-service): add unique slug check when creating project
Piyush Guptaa35dc858ba6d
diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.tsindex e29f18404f..dce0ed2cc7 100644--- a/backend/src/services/project/project-service.ts+++ b/backend/src/services/project/project-service.ts@@ -303,13 +303,26 @@ export const projectServiceFactory = ({});}+ const slug = projectSlug || slugify(`${workspaceName}-${alphaNumericNanoId(4)}`);++ const existingProject = await projectDAL.findOne({+ slug,+ orgId: organization.id+ });++ if (existingProject) {+ throw new BadRequestError({+ message: `Failed to create project. A project with the slug "${slug}" already exists in your organization. Please choose a different name or slug.`+ });+ }+const project = await projectDAL.create({name: workspaceName,type,description: workspaceDescription,orgId: organization.id,- slug: projectSlug || slugify(`${workspaceName}-${alphaNumericNanoId(4)}`),+ slug,kmsSecretManagerKeyId: kmsKeyId,version: ProjectVersion.V3,pitVersionLimit: 10