From b230687c8a74b2c786ed13b21f94f2c89c68a8fa Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Fri, 12 Dec 2025 10:14:03 -0600 Subject: [PATCH 1/2] fix(environment): prevent renaming of the default environment - Updated the logic to disallow renaming the default environment while still allowing updates to its description and other properties. - Adjusted error message for clarity when attempting to rename the default environment. --- apps/dokploy/server/api/routers/environment.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/server/api/routers/environment.ts b/apps/dokploy/server/api/routers/environment.ts index 5a7f625d4..63863b26e 100644 --- a/apps/dokploy/server/api/routers/environment.ts +++ b/apps/dokploy/server/api/routers/environment.ts @@ -256,10 +256,11 @@ export const environmentRouter = createTRPCRouter({ } const currentEnvironment = await findEnvironmentById(environmentId); - if (currentEnvironment.isDefault) { + // Prevent renaming the default environment, but allow updating env and description + if (currentEnvironment.isDefault && updateData.name !== undefined) { throw new TRPCError({ code: "BAD_REQUEST", - message: "You cannot update the default environment", + message: "You cannot rename the default environment", }); } if ( From 1c83919408a05f753d02715329bf9140d80f842a Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Fri, 12 Dec 2025 10:15:16 -0600 Subject: [PATCH 2/2] 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,