From 1ce15da7ce6d643f97aa1faf6cfef8902971fe28 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Fri, 5 Sep 2025 01:14:44 -0600 Subject: [PATCH] feat: add validation to prevent use of 'production' as environment name in creation and update operations, enhancing error handling in environment management --- apps/dokploy/server/api/routers/environment.ts | 15 +++++++++++++++ packages/server/src/utils/backups/web-server.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/dokploy/server/api/routers/environment.ts b/apps/dokploy/server/api/routers/environment.ts index 91d565655..98c565134 100644 --- a/apps/dokploy/server/api/routers/environment.ts +++ b/apps/dokploy/server/api/routers/environment.ts @@ -58,6 +58,13 @@ export const environmentRouter = createTRPCRouter({ // This would typically involve checking project ownership/membership // For now, we'll use a basic organization check + if (input.name === "production") { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Environment name cannot be production", + }); + } + const environment = await createEnvironment(input); if (ctx.user.role === "member") { @@ -229,6 +236,14 @@ export const environmentRouter = createTRPCRouter({ .mutation(async ({ input, ctx }) => { try { const { environmentId, ...updateData } = input; + + if (updateData.name === "production") { + throw new TRPCError({ + code: "BAD_REQUEST", + message: "Environment name cannot be production", + }); + } + if (ctx.user.role === "member") { await checkEnvironmentAccess( ctx.user.id, diff --git a/packages/server/src/utils/backups/web-server.ts b/packages/server/src/utils/backups/web-server.ts index 923f03fd8..4d13ae31a 100644 --- a/packages/server/src/utils/backups/web-server.ts +++ b/packages/server/src/utils/backups/web-server.ts @@ -80,7 +80,7 @@ export const runWebServerBackup = async (backup: BackupSchedule) => { writeStream.write("Zipped database and filesystem\n"); const uploadCommand = `rclone copyto ${rcloneFlags.join(" ")} "${tempDir}/${backupFileName}" "${s3Path}"`; - writeStream.write(`Running command: ${uploadCommand}\n`); + writeStream.write("Running command to upload backup to S3\n"); await execAsync(uploadCommand); writeStream.write("Uploaded backup to S3 ✅\n"); writeStream.end();