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

View File

@@ -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 }];
}

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 }));
} 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 }];
}