Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix: resolved failing project delete
=f1b20285421d
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 9ed38a7e35..3e5575daa5 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -895,7 +895,8 @@ export const registerRoutes = async (certificateTemplateDAL,projectSlackConfigDAL,slackIntegrationDAL,- projectTemplateService+ projectTemplateService,+ groupProjectDAL});const projectEnvService = projectEnvServiceFactory({diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.tsindex b5046be63f..e1653d3713 100644--- a/backend/src/services/project/project-service.ts+++ b/backend/src/services/project/project-service.ts@@ -29,6 +29,7 @@ import { ActorType } from "../auth/auth-type";import { TCertificateDALFactory } from "../certificate/certificate-dal";import { TCertificateAuthorityDALFactory } from "../certificate-authority/certificate-authority-dal";import { TCertificateTemplateDALFactory } from "../certificate-template/certificate-template-dal";+import { TGroupProjectDALFactory } from "../group-project/group-project-dal";import { TIdentityOrgDALFactory } from "../identity/identity-org-dal";import { TIdentityProjectDALFactory } from "../identity-project/identity-project-dal";import { TIdentityProjectMembershipRoleDALFactory } from "../identity-project/identity-project-membership-role-dal";@@ -100,7 +101,8 @@ type TProjectServiceFactoryDep = {identityProjectDAL: TIdentityProjectDALFactory;identityProjectMembershipRoleDAL: Pick<TIdentityProjectMembershipRoleDALFactory, "create">;projectKeyDAL: Pick<TProjectKeyDALFactory, "create" | "findLatestProjectKey" | "delete" | "find" | "insertMany">;- projectMembershipDAL: Pick<TProjectMembershipDALFactory, "create" | "findProjectGhostUser" | "findOne">;+ projectMembershipDAL: Pick<TProjectMembershipDALFactory, "create" | "findProjectGhostUser" | "findOne" | "delete">;+ groupProjectDAL: Pick<TGroupProjectDALFactory, "delete">;projectSlackConfigDAL: Pick<TProjectSlackConfigDALFactory, "findOne" | "transaction" | "updateById" | "create">;slackIntegrationDAL: Pick<TSlackIntegrationDALFactory, "findById" | "findByIdWithWorkflowIntegrationDetails">;projectUserMembershipRoleDAL: Pick<TProjectUserMembershipRoleDALFactory, "create">;@@ -120,7 +122,7 @@ type TProjectServiceFactoryDep = {orgDAL: Pick<TOrgDALFactory, "findOne">;keyStore: Pick<TKeyStoreFactory, "deleteItem">;projectBotDAL: Pick<TProjectBotDALFactory, "create">;- projectRoleDAL: Pick<TProjectRoleDALFactory, "find" | "insertMany">;+ projectRoleDAL: Pick<TProjectRoleDALFactory, "find" | "insertMany" | "delete">;kmsService: Pick<TKmsServiceFactory,| "updateProjectSecretManagerKmsKey"@@ -169,7 +171,8 @@ export const projectServiceFactory = ({projectBotDAL,projectSlackConfigDAL,slackIntegrationDAL,- projectTemplateService+ projectTemplateService,+ groupProjectDAL}: TProjectServiceFactoryDep) => {/** Create workspace. Make user the admin@@ -444,13 +447,32 @@ export const projectServiceFactory = ({ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Project);const deletedProject = await projectDAL.transaction(async (tx) => {+ // delete these so that project custom roles can be deleted in cascade effect+ // direct deletion of project without these will cause fk error+ await projectMembershipDAL.delete({ projectId: project.id }, tx);+ await groupProjectDAL.delete({ projectId: project.id }, tx);const delProject = await projectDAL.deleteById(project.id, tx);const projectGhostUser = await projectMembershipDAL.findProjectGhostUser(project.id, tx).catch(() => null);+ // akhilmhdh: before removing those kms checking any other project uses it+ // happened due to project splitif (delProject.kmsCertificateKeyId) {- await kmsService.deleteInternalKms(delProject.kmsCertificateKeyId, delProject.orgId, tx);+ const projectsLinkedToForiegnKey = await projectDAL.find(+ { kmsCertificateKeyId: delProject.kmsCertificateKeyId },+ { tx }+ );+ if (!projectsLinkedToForiegnKey.length) {+ await kmsService.deleteInternalKms(delProject.kmsCertificateKeyId, delProject.orgId, tx);+ }}+if (delProject.kmsSecretManagerKeyId) {- await kmsService.deleteInternalKms(delProject.kmsSecretManagerKeyId, delProject.orgId, tx);+ const projectsLinkedToForiegnKey = await projectDAL.find(+ { kmsSecretManagerKeyId: delProject.kmsSecretManagerKeyId },+ { tx }+ );+ if (!projectsLinkedToForiegnKey.length) {+ await kmsService.deleteInternalKms(delProject.kmsSecretManagerKeyId, delProject.orgId, tx);+ }}// Delete the org membership for the ghost user if it's found.if (projectGhostUser) {