Merge pull request #4419 from Infisical/daniel/throw-on-invalid-env

fix(secrets-service): throw on invalid env / path
This commit is contained in:
Daniel Hougaard
2025-08-26 20:53:16 +02:00
committed by GitHub
2 changed files with 24 additions and 4 deletions
@@ -1074,12 +1074,22 @@ export const secretV2BridgeServiceFactory = ({
currentPath: path currentPath: path
}); });
if (!deepPaths) return { secrets: [], imports: [] }; if (!deepPaths?.length) {
throw new NotFoundError({
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
name: "SecretPathNotFound"
});
}
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p })); paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
} else { } else {
const folder = await folderDAL.findBySecretPath(projectId, environment, path); const folder = await folderDAL.findBySecretPath(projectId, environment, path);
if (!folder) return { secrets: [], imports: [] }; if (!folder) {
throw new NotFoundError({
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
name: "SecretPathNotFound"
});
}
paths = [{ folderId: folder.id, path }]; paths = [{ folderId: folder.id, path }];
} }
+12 -2
View File
@@ -637,7 +637,12 @@ export const secretServiceFactory = ({
} }
}); });
if (!deepPaths) return { secrets: [], imports: [] }; if (!deepPaths?.length) {
throw new NotFoundError({
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
name: "SecretPathNotFound"
});
}
paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p })); paths = deepPaths.map(({ folderId, path: p }) => ({ folderId, path: p }));
} else { } else {
@@ -647,7 +652,12 @@ export const secretServiceFactory = ({
}); });
const folder = await folderDAL.findBySecretPath(projectId, environment, path); const folder = await folderDAL.findBySecretPath(projectId, environment, path);
if (!folder) return { secrets: [], imports: [] }; if (!folder) {
throw new NotFoundError({
message: `Folder with path '${path}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
name: "SecretPathNotFound"
});
}
paths = [{ folderId: folder.id, path }]; paths = [{ folderId: folder.id, path }];
} }