From 1c83919408a05f753d02715329bf9140d80f842a Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Fri, 12 Dec 2025 10:15:16 -0600 Subject: [PATCH] fix(environment): prevent deletion of the default environment - Added logic to disallow deletion of the default environment, throwing a BAD_REQUEST error if an attempt is made to delete it. --- apps/dokploy/server/api/routers/environment.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/dokploy/server/api/routers/environment.ts b/apps/dokploy/server/api/routers/environment.ts index 63863b26e..9f5eb45c2 100644 --- a/apps/dokploy/server/api/routers/environment.ts +++ b/apps/dokploy/server/api/routers/environment.ts @@ -208,6 +208,14 @@ export const environmentRouter = createTRPCRouter({ }); } + // Prevent deletion of the default environment + if (environment.isDefault) { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "You cannot delete the default environment", + }); + } + // Check environment deletion permission await checkEnvironmentDeletionPermission( ctx.user.id,