From 60dc1d1e00003644c4cae56ddd26acddeed7e106 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Wed, 6 Aug 2025 19:58:35 +0400 Subject: [PATCH 1/2] fix: improve vault folders mapping --- .../external-migration-fns/vault.ts | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) 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 b512ff11a..1ebd56a80 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 pathParts = path.split("/").filter(Boolean); + const folderParts = pathParts; - 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}`; - // 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)!; - } + 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)!; } } From 000dd6c223c970618d33ea0c01ec502e1da4ad24 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Thu, 7 Aug 2025 00:43:07 +0400 Subject: [PATCH 2/2] Update external-migration-router.ts --- backend/src/server/routes/v3/external-migration-router.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/server/routes/v3/external-migration-router.ts b/backend/src/server/routes/v3/external-migration-router.ts index 89621811d..4325692da 100644 --- a/backend/src/server/routes/v3/external-migration-router.ts +++ b/backend/src/server/routes/v3/external-migration-router.ts @@ -19,7 +19,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider config: { rateLimit: writeLimit }, - onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), + onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { const data = await req.file({ limits: { @@ -69,7 +69,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider mappingType: z.nativeEnum(VaultMappingType) }) }, - onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), + onRequest: verifyAuth([AuthMode.JWT]), handler: async (req) => { await server.services.migration.importVaultData({ actorId: req.permission.id,