Skip to content

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

fix: improve vault folders mapping

Daniel Hougaard60dc1d1e0000
diff --git a/backend/src/services/external-migration/external-migration-fns/vault.ts b/backend/src/services/external-migration/external-migration-fns/vault.ts
index b512ff11a2..1ebd56a80f 100644
--- a/backend/src/services/external-migration/external-migration-fns/vault.ts
+++ b/backend/src/services/external-migration/external-migration-fns/vault.ts
@@ -254,29 +254,26 @@ export const transformToInfisicalFormatNamespaceToProjects = (
let currentFolderId: string | undefined;
let currentPath = "";
- if (path.includes("/")) {
- const pathParts = path.split("/").filter(Boolean);
-
- const folderParts = pathParts;
-
- // create nested folder structure for the entire path
- for (const folderName of folderParts) {
- currentPath = currentPath ? `${currentPath}/${folderName}` : folderName;
- const folderKey = `${namespace}:${mount}:${currentPath}`;
-
- if (!folderMap.has(folderKey)) {
- const folderId = uuidv4();
- folderMap.set(folderKey, folderId);
- folders.push({
- id: folderId,
- name: folderName,
- environmentId,
- parentFolderId: currentFolderId || environmentId
- });
- currentFolderId = folderId;
- } else {
- currentFolderId = folderMap.get(folderKey)!;
- }
+ const pathParts = path.split("/").filter(Boolean);
+ const folderParts = pathParts;
+
+ // create nested folder structure for the entire path
+ for (const folderName of folderParts) {
+ currentPath = currentPath ? `${currentPath}/${folderName}` : folderName;
+ const folderKey = `${namespace}:${mount}:${currentPath}`;
+
+ if (!folderMap.has(folderKey)) {
+ const folderId = uuidv4();
+ folderMap.set(folderKey, folderId);
+ folders.push({
+ id: folderId,
+ name: folderName,
+ environmentId,
+ parentFolderId: currentFolderId || environmentId
+ });
+ currentFolderId = folderId;
+ } else {
+ currentFolderId = folderMap.get(folderKey)!;
}
}