Skip to content

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

fix(project-dal): add error handling for non-existent projects in checkProjectUpgradeStatus function

Victor Hugo dos Santos7689e4001e84
diff --git a/backend/src/services/project/project-dal.ts b/backend/src/services/project/project-dal.ts
index 2974245f29..9f790a8cb9 100644
--- a/backend/src/services/project/project-dal.ts
+++ b/backend/src/services/project/project-dal.ts
@@ -545,8 +545,11 @@ export const projectDALFactory = (db: TDbClient) => {
const checkProjectUpgradeStatus = async (projectId: string) => {
const project = await findById(projectId);
+ if (!project) {
+ throw new NotFoundError({ message: `Project with ID '${projectId}' not found` });
+ }
const upgradeInProgress =
- project?.upgradeStatus === ProjectUpgradeStatus.InProgress && project?.version === ProjectVersion.V1;
+ project.upgradeStatus === ProjectUpgradeStatus.InProgress && project.version === ProjectVersion.V1;
if (upgradeInProgress) {
throw new BadRequestError({