requested changes

This commit is contained in:
Daniel Hougaard
2025-08-26 20:25:41 +02:00
parent 8f00bab61c
commit 2f375d6b65
3 changed files with 25 additions and 45 deletions

View File

@@ -22,26 +22,6 @@ const INTERPOLATION_TEST_REGEX = new RE2(INTERPOLATION_PATTERN_STRING);
export const shouldUseSecretV2Bridge = (version: number) => version === 3;
export const validateSecretPath = async (
data: {
projectId: string;
environment: string;
secretPath: string;
},
folderDAL: Pick<TSecretFolderDALFactory, "findBySecretPath">
) => {
const { projectId, environment, secretPath } = data;
const folder = await folderDAL.findBySecretPath(projectId, environment, secretPath);
if (!folder) {
throw new NotFoundError({
message: `Folder with path '${secretPath}' in environment '${environment}' was not found. Please ensure the environment slug and secret path is correct.`,
name: "SecretPathNotFound"
});
}
};
/**
* Grabs and processes nested secret references from a string
*

View File

@@ -64,8 +64,7 @@ import {
generatePaths,
getAllSecretReferences,
recursivelyGetSecretPaths,
reshapeBridgeSecret,
validateSecretPath
reshapeBridgeSecret
} from "./secret-v2-bridge-fns";
import {
SecretOperations,
@@ -1041,15 +1040,6 @@ export const secretV2BridgeServiceFactory = ({
projectId
});
await validateSecretPath(
{
projectId,
environment,
secretPath: path
},
folderDAL
);
const encryptedCachedSecrets = await keyStore.getItem(cacheKey);
if (encryptedCachedSecrets) {
try {
@@ -1084,12 +1074,22 @@ export const secretV2BridgeServiceFactory = ({
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 }));
} else {
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 }];
}

View File

@@ -97,7 +97,6 @@ import {
} from "./secret-types";
import { TSecretVersionDALFactory } from "./secret-version-dal";
import { TSecretVersionTagDALFactory } from "./secret-version-tag-dal";
import { validateSecretPath } from "../secret-v2-bridge/secret-v2-bridge-fns";
type TSecretServiceFactoryDep = {
secretDAL: TSecretDALFactory;
@@ -617,15 +616,6 @@ export const secretServiceFactory = ({
actionProjectType: ActionProjectType.SecretManager
});
await validateSecretPath(
{
projectId,
environment,
secretPath: path
},
folderDAL
);
let paths: { folderId: string; path: string }[] = [];
if (recursive) {
@@ -647,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 }));
} else {
@@ -657,7 +652,12 @@ export const secretServiceFactory = ({
});
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 }];
}