From d0bfac3e8abfca5ba3019de1ff01690141027b42 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Fri, 2 May 2025 11:03:48 +0530 Subject: [PATCH] Revert "fix: Read admin emails for migration from the docker.env file directly" (#40542) Reverts appsmithorg/appsmith#40520 ## Summary by CodeRabbit - **Refactor** - Improved how admin email environment variables are retrieved, resulting in a simpler and more reliable setup process for super user configuration. No changes to user-facing functionality. --- .../db/ce/Migration10000_UpdateSuperUser.java | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration10000_UpdateSuperUser.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration10000_UpdateSuperUser.java index bd4b43c2aa..91bd2e9055 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration10000_UpdateSuperUser.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration10000_UpdateSuperUser.java @@ -1,7 +1,6 @@ package com.appsmith.server.migrations.db.ce; import com.appsmith.server.acl.PolicyGenerator; -import com.appsmith.server.configurations.CommonConfig; import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Config; import com.appsmith.server.domains.Organization; @@ -10,7 +9,6 @@ import com.appsmith.server.domains.User; import com.appsmith.server.helpers.TextUtils; import com.appsmith.server.migrations.solutions.UpdateSuperUserMigrationHelper; import com.appsmith.server.repositories.CacheableRepositoryHelper; -import com.appsmith.server.solutions.EnvManager; import com.appsmith.server.solutions.PolicySolution; import io.mongock.api.annotations.ChangeUnit; import io.mongock.api.annotations.Execution; @@ -20,11 +18,6 @@ import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -47,22 +40,16 @@ public class Migration10000_UpdateSuperUser { private final PolicySolution policySolution; private final PolicyGenerator policyGenerator; private final UpdateSuperUserMigrationHelper updateSuperUserMigrationHelper; - private final CommonConfig commonConfig; - private final EnvManager envManager; public Migration10000_UpdateSuperUser( MongoTemplate mongoTemplate, CacheableRepositoryHelper cacheableRepositoryHelper, PolicySolution policySolution, - PolicyGenerator policyGenerator, - CommonConfig commonConfig, - EnvManager envManager) { + PolicyGenerator policyGenerator) { this.mongoTemplate = mongoTemplate; this.cacheableRepositoryHelper = cacheableRepositoryHelper; this.policySolution = policySolution; this.policyGenerator = policyGenerator; - this.commonConfig = commonConfig; - this.envManager = envManager; this.updateSuperUserMigrationHelper = new UpdateSuperUserMigrationHelper(); } @@ -72,22 +59,7 @@ public class Migration10000_UpdateSuperUser { @Execution public void executeMigration() { // Read the admin emails from the environment and update the super users accordingly - String originalContent = ""; - try { - originalContent = Files.readString(Path.of(commonConfig.getEnvFilePath())); - } catch (NoSuchFileException e) { - log.error("Env file not found at " + commonConfig.getEnvFilePath(), e); - // No need to throw an exception here, as this is a non-critical migration - return; - } catch (IOException e) { - log.error("Unable to read env file " + commonConfig.getEnvFilePath(), e); - // No need to throw an exception here, as this is a non-critical migration - return; - } - - Map envVariableMap = envManager.parseToMap(originalContent); - // Get the admin emails from the environment variable - String adminEmailsStr = envVariableMap.get(APPSMITH_ADMIN_EMAILS.name()); + String adminEmailsStr = System.getenv(String.valueOf(APPSMITH_ADMIN_EMAILS)); Set adminEmails = TextUtils.csvToSet(adminEmailsStr);