Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix update

Thiago Araujo da Silvacd0e286a0897
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.ts
index 34125bcae8..8d0bde3f61 100644
--- a/backend/src/ee/services/group/group-service.ts
+++ b/backend/src/ee/services/group/group-service.ts
@@ -277,19 +277,22 @@ export const groupServiceFactory = ({
if (isCustomRole) customRole = rolePermissionDetails?.role;
}
- if (!isLinkedGroup && name) {
- const existingGroup = await groupDAL.findOne({ orgId: actorOrgId, name });
- if (existingGroup && existingGroup.id !== id) {
- throw new BadRequestError({
- message: `Failed to update group with name '${name}'. Group with the same name already exists`
- });
- }
- }
-
const updatedGroup = await groupDAL.transaction(async (tx): Promise<TGroups> => {
const [nameSlugRow] =
!isLinkedGroup && (name || slug)
- ? await groupDAL.update({ id: group.id }, { name, slug: slug ? slugify(slug) : undefined }, tx)
+ ? await groupDAL
+ .update({ id: group.id }, { name, slug: slug ? slugify(slug) : undefined }, tx)
+ .catch((err) => {
+ if (
+ err instanceof DatabaseError &&
+ (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation
+ ) {
+ throw new BadRequestError({
+ message: `This name or slug is already in use by another group in your organization. Please choose a different one.`
+ });
+ }
+ throw err;
+ })
: [];
if (role) {