Skip to content

Commit 7cf898d

Browse files
authored
Merge pull request #3251 from Dokploy/3247-cannot-edit-production-environment-variables
fix(environment): prevent renaming of the default environment
2 parents b499cef + 1c83919 commit 7cf898d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/dokploy/server/api/routers/environment.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ export const environmentRouter = createTRPCRouter({
208208
});
209209
}
210210

211+
// Prevent deletion of the default environment
212+
if (environment.isDefault) {
213+
throw new TRPCError({
214+
code: "BAD_REQUEST",
215+
message: "You cannot delete the default environment",
216+
});
217+
}
218+
211219
// Check environment deletion permission
212220
await checkEnvironmentDeletionPermission(
213221
ctx.user.id,
@@ -256,10 +264,11 @@ export const environmentRouter = createTRPCRouter({
256264
}
257265
const currentEnvironment = await findEnvironmentById(environmentId);
258266

259-
if (currentEnvironment.isDefault) {
267+
// Prevent renaming the default environment, but allow updating env and description
268+
if (currentEnvironment.isDefault && updateData.name !== undefined) {
260269
throw new TRPCError({
261270
code: "BAD_REQUEST",
262-
message: "You cannot update the default environment",
271+
message: "You cannot rename the default environment",
263272
});
264273
}
265274
if (

0 commit comments

Comments
 (0)