Merge pull request #4690 from Infisical/fix/error-on-duplicate-folder-creation

fix: returns error on duplicate folder creation
This commit is contained in:
Piyush Gupta
2025-10-20 08:49:43 +05:30
committed by GitHub
7 changed files with 144 additions and 34 deletions
@@ -118,24 +118,11 @@ export const secretFolderServiceFactory = ({
});
}
// check if the exact folder already exists
const existingFolder = await folderDAL.findOne(
{
envId: env.id,
parentId: parentFolder.id,
name,
isReserved: false
},
tx
);
if (existingFolder) {
return existingFolder;
}
// exact folder case
if (parentFolder.path === pathWithFolder) {
return parentFolder;
throw new BadRequestError({
message: `Folder with name '${name}' already exists in path '${secretPath}'`
});
}
let currentParentId = parentFolder.id;