diff --git a/app/server/appsmith-git/src/main/java/com/appsmith/git/constants/Constraint.java b/app/server/appsmith-git/src/main/java/com/appsmith/git/constants/Constraint.java index e005c6b311..ef9bc7071f 100644 --- a/app/server/appsmith-git/src/main/java/com/appsmith/git/constants/Constraint.java +++ b/app/server/appsmith-git/src/main/java/com/appsmith/git/constants/Constraint.java @@ -2,6 +2,6 @@ package com.appsmith.git.constants; public class Constraint { public static final int MAX_COMMIT_LOGS = 100; - public static final int REMOTE_TIMEOUT_MILLIS = 20000; - public static final int LOCAL_TIMEOUT_MILLIS = 5000; + public static final int REMOTE_TIMEOUT_MILLIS = 60000; + public static final int LOCAL_TIMEOUT_MILLIS = 10000; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java index 4c2cde1e25..b8242c9509 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java @@ -135,6 +135,7 @@ public enum AppsmithError { GIT_PULL_CONFLICTS(400, 4047, "Merge conflicts found during the pull operation: {0}", AppsmithErrorAction.DEFAULT, null, ErrorType.GIT_ACTION_EXECUTION_ERROR, ErrorReferenceDocUrl.GIT_PULL_CONFLICT), SSH_KEY_GENERATION_ERROR(500, 5015, "Failed to generate SSH keys, please contact Appsmith support for more details", AppsmithErrorAction.DEFAULT, null, ErrorType.GIT_CONFIGURATION_ERROR, null), GIT_UPSTREAM_CHANGES(400, 4048, "Looks like there are pending upstream changes. To prevent you from losing history, we will pull the changes and push them to your repo.", AppsmithErrorAction.DEFAULT, null, ErrorType.GIT_ACTION_EXECUTION_ERROR, ErrorReferenceDocUrl.GIT_UPSTREAM_CHANGES), + GIT_GENERIC_ERROR(504, 5016, "Git command execution error: {0}", AppsmithErrorAction.DEFAULT, null, ErrorType.GIT_ACTION_EXECUTION_ERROR, null), ; private final Integer httpErrorCode; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java index 2fa32e71a1..1d722d1004 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GitServiceCEImpl.java @@ -675,7 +675,7 @@ public class GitServiceCEImpl implements GitServiceCE { gitApplicationMetadata.getGitAuth().getPublicKey() ) .onErrorResume(error -> { - log.error("Error while cloning the remote repo, {}", error.getMessage()); + log.error("Error while cloning the remote repo, ", error); return addAnalyticsForGitOperation( AnalyticsEvents.GIT_CONNECT.getEventName(), application, @@ -690,7 +690,10 @@ public class GitServiceCEImpl implements GitServiceCE { if (error instanceof InvalidRemoteException) { return Mono.error(new AppsmithException(AppsmithError.INVALID_GIT_CONFIGURATION, error.getMessage())); } - return Mono.error(new AppsmithException(AppsmithError.GIT_EXECUTION_TIMEOUT)); + if (error instanceof TimeoutException) { + return Mono.error(new AppsmithException(AppsmithError.GIT_EXECUTION_TIMEOUT)); + } + return Mono.error(new AppsmithException(AppsmithError.GIT_GENERIC_ERROR, error.getMessage())); }); }); return Mono.zip( diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/GitServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/GitServiceTest.java index 0267c09e1c..0862263bd9 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/GitServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/GitServiceTest.java @@ -455,6 +455,23 @@ public class GitServiceTest { .verify(); } + @Test + @WithUserDetails(value = "api_user") + public void connectApplicationToGit_cloneException_throwGitException() throws IOException { + + Mockito.when(gitExecutor.cloneApplication(Mockito.any(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + .thenReturn(Mono.error(new Exception("error message"))); + + GitConnectDTO gitConnectDTO = getConnectRequest("git@github.com:test/testRepo.git", testUserProfile); + Mono applicationMono = gitService.connectApplicationToGit(gitConnectedApplication.getId(), gitConnectDTO, "baseUrl"); + + StepVerifier + .create(applicationMono) + .expectErrorMatches(throwable -> throwable instanceof AppsmithException + && throwable.getMessage().equals(AppsmithError.GIT_GENERIC_ERROR.getMessage("error message"))) + .verify(); + } + @Test @WithUserDetails(value = "api_user") public void connectApplicationToGit_WithEmptyPublishedPages_CloneSuccess() throws IOException { @@ -2295,11 +2312,10 @@ public class GitServiceTest { .map(Organization::getId) .block(); - GitConnectDTO gitConnectDTO = getConnectRequest("git@github.com:test/testGitImportRepo.git", testUserProfile); + GitConnectDTO gitConnectDTO = getConnectRequest("git@github.com:test/testGitImportRepoCancelledMidway.git", testUserProfile); GitAuth gitAuth = gitService.generateSSHKey().block(); ApplicationJson applicationJson = createAppJson(filePath).block(); - applicationJson.getExportedApplication().setName("testGitImportRepoCancelledMidway"); applicationJson.getDatasourceList().get(0).setName("db-auth-testGitImportRepo"); String pluginId = pluginRepository.findByPackageName("mongo-plugin").block().getId(); @@ -2341,7 +2357,7 @@ public class GitServiceTest { assertThat(application.getGitApplicationMetadata()).isNotNull(); assertThat(application.getGitApplicationMetadata().getBranchName()).isEqualTo("defaultBranch"); assertThat(application.getGitApplicationMetadata().getDefaultBranchName()).isEqualTo("defaultBranch"); - assertThat(application.getGitApplicationMetadata().getRemoteUrl()).isEqualTo("git@github.com:test/testGitImportRepo.git"); + assertThat(application.getGitApplicationMetadata().getRemoteUrl()).isEqualTo("git@github.com:test/testGitImportRepoCancelledMidway.git"); assertThat(application.getGitApplicationMetadata().getIsRepoPrivate()).isEqualTo(true); assertThat(application.getGitApplicationMetadata().getGitAuth().getPublicKey()).isEqualTo(gitAuth.getPublicKey());