Skip to content

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

fix: moving duplication check outside of transaction

IgorHortaa4eed126e9df
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.ts
index d8a7b51c01..a16fb14583 100644
--- a/backend/src/ee/services/group/group-service.ts
+++ b/backend/src/ee/services/group/group-service.ts
@@ -258,16 +258,16 @@ export const groupServiceFactory = ({
if (isCustomRole) customRole = rolePermissionDetails?.role;
}
- const updatedGroup = await groupDAL.transaction(async (tx): Promise<TGroups> => {
- if (!isLinkedGroup && (name || slug) && name) {
- const existingGroup = await groupDAL.findOne({ orgId: actorOrgId, name }, tx);
- if (existingGroup && existingGroup.id !== id) {
- throw new BadRequestError({
- message: `Failed to update group with name '${name}'. Group with the same name already exists`
- });
- }
+ 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)