mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Merge pull request #4419 from Infisical/daniel/throw-on-invalid-env
fix(secrets-service): throw on invalid env / path
This commit is contained in:
@@ -1074,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 }];
|
||||
}
|
||||
|
||||
@@ -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 }));
|
||||
} else {
|
||||
@@ -647,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 }];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user