Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: proper errors on failed to find env

Daniel Hougaard01920d7a507f
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
index 2ee32a7d7b..1ae7ce6dc2 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
@@ -1,7 +1,7 @@
import path from "node:path";
import { TableName, TSecretFolders, TSecretsV2 } from "@app/db/schemas";
-import { ForbiddenRequestError } from "@app/lib/errors";
+import { ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { groupBy } from "@app/lib/fn";
import { logger } from "@app/lib/logger";
@@ -342,7 +342,7 @@ export const recursivelyGetSecretPaths = async ({
});
if (!env) {
- throw new Error(`'${environment}' environment not found in project with ID ${projectId}`);
+ throw new NotFoundError({ message: `'${environment}' environment not found in project with ID ${projectId}` });
}
// Fetch all folders in env once with a single query
diff --git a/backend/src/services/secret/secret-fns.ts b/backend/src/services/secret/secret-fns.ts
index 3afde2f1eb..1d0b89b467 100644
--- a/backend/src/services/secret/secret-fns.ts
+++ b/backend/src/services/secret/secret-fns.ts
@@ -152,7 +152,7 @@ export const recursivelyGetSecretPaths = ({
});
if (!env) {
- throw new Error(`'${environment}' environment not found in project with ID ${projectId}`);
+ throw new NotFoundError({ message: `'${environment}' environment not found in project with ID ${projectId}` });
}
// Fetch all folders in env once with a single query