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.
This commit is contained in:
Mauricio Siu
2025-12-12 10:15:16 -06:00
parent b230687c8a
commit 1c83919408

View File

@@ -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,