From 6b6faccde25c8976311a307f6e65180f7072c8e1 Mon Sep 17 00:00:00 2001 From: Manish Kumar <107841575+sondermanish@users.noreply.github.com> Date: Fri, 11 Apr 2025 14:07:44 +0530 Subject: [PATCH] fix: added null checks for accessing published actionDTO before export (#40215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Fixes #https://github.com/appsmithorg/appsmith/issues/40159 ## Automation /ok-to-test tags="@tag.Git, @tag.ImportExport" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 42379619c5e7b6ca6761688d510cafb37991df87 > Cypress dashboard. > Tags: `@tag.Git, @tag.ImportExport` > Spec: >
Fri, 11 Apr 2025 06:25:22 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Bug Fixes** - Improved data export to ensure all relevant fields are correctly sanitized. - Added safety checks to prevent potential runtime errors during action processing. - **Refactor** - Enhanced asynchronous processing flow for more robust operation handling. --- .../src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java | 1 - .../java/com/appsmith/external/models/RefAwareDomain.java | 2 ++ .../java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java | 2 +- .../server/newactions/base/NewActionServiceCEImpl.java | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java index e8aaf2898e..8503257247 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java @@ -719,7 +719,6 @@ public class FileUtilsCEImpl implements FileInterface { @Override public Mono constructGitResourceMapFromGitRepo(Path repositorySuffix, String refName) { - // TODO: check that we need to checkout to the ref Path repositoryPath = Paths.get(gitServiceConfig.getGitRootPath()).resolve(repositorySuffix); return Mono.fromCallable(() -> fetchGitResourceMap(repositoryPath)).subscribeOn(scheduler); } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/RefAwareDomain.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/RefAwareDomain.java index 16b40bd91f..37b2db1f6d 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/RefAwareDomain.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/RefAwareDomain.java @@ -55,6 +55,8 @@ public abstract class RefAwareDomain extends GitSyncedDomain { public void sanitiseToExportDBObject() { this.setBaseId(null); this.setBranchName(null); + this.setRefType(null); + this.setRefName(null); super.sanitiseToExportDBObject(); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java index 7194455ae1..59e69f75b9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java @@ -288,7 +288,7 @@ public class GitFSServiceCEImpl implements GitHandlingServiceCE { return fsGitHandler .resetToLastCommit(repoSuffix) - .then(commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics( + .flatMap(resetFlag -> commonGitFileUtils.constructArtifactExchangeJsonFromGitRepositoryWithAnalytics( artifactJsonTransformationDTO)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java index ba9cc4ed0b..be6122088e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java @@ -1480,7 +1480,9 @@ public class NewActionServiceCEImpl extends BaseService unpublishedPages, Optional optionalPermission) { return repository.findByPageIds(unpublishedPages, optionalPermission).doOnNext(newAction -> { this.setCommonFieldsFromNewActionIntoAction(newAction, newAction.getUnpublishedAction()); - this.setCommonFieldsFromNewActionIntoAction(newAction, newAction.getPublishedAction()); + if (newAction.getPublishedAction() != null) { + this.setCommonFieldsFromNewActionIntoAction(newAction, newAction.getPublishedAction()); + } }); }