diff --git a/app/server/.gitignore b/app/server/.gitignore index 37ae9e3606..be48d9bfcc 100644 --- a/app/server/.gitignore +++ b/app/server/.gitignore @@ -4,3 +4,9 @@ target/** **/.idea **/target **/dist +.settings/** +**/.settings +**/.classpath +**/.project +**/.factorypath +**.iml \ No newline at end of file diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/acl/AclService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/acl/AclService.java index 3b717f1c0c..e928577e33 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/acl/AclService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/acl/AclService.java @@ -79,7 +79,7 @@ public class AclService { .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .build(); - WebClient.RequestHeadersSpec request = webClient.post().syncBody(requestBody.toString()); + WebClient.RequestHeadersSpec request = webClient.post().bodyValue(requestBody.toString()); return request.retrieve().bodyToMono(OpaResponse.class); }); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java index 3a250e66dd..d01c34fc4d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java @@ -10,6 +10,7 @@ import lombok.ToString; import org.springframework.data.annotation.Transient; import org.springframework.data.mongodb.core.mapping.Document; +import java.util.Map; import java.util.Set; @Getter @@ -35,6 +36,11 @@ public class Action extends BaseDomain { Boolean executeOnLoad; + /* This is a list of fields specified by the client to signify which fields have dynamic bindings in them. + TODO: The server can use this field to simplify our Mustache substitutions in the future + */ + Map dynamicBindings; + @JsonProperty(access = JsonProperty.Access.READ_ONLY) Boolean isValid; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java index 5bfcdc1420..ac3677bdd9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ActionServiceImpl.java @@ -8,6 +8,8 @@ import com.appsmith.external.models.PaginationType; import com.appsmith.external.models.Param; import com.appsmith.external.models.Property; import com.appsmith.external.models.Provider; +import com.appsmith.external.pluginExceptions.AppsmithPluginError; +import com.appsmith.external.pluginExceptions.AppsmithPluginException; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.server.constants.AnalyticsEvents; import com.appsmith.server.constants.FieldName; @@ -432,6 +434,12 @@ public class ActionServiceImpl extends BaseService populateRequestFields(actionConfiguration, (ActionExecutionResult) obj)); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java index 771298f492..84f79adf20 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java @@ -203,7 +203,7 @@ public class MarketplaceServiceImpl implements MarketplaceService { if (params != null) { for (String key : params.keySet()) { - uriBuilder.queryParam(key, URLEncoder.encode(params.getFirst(key))); + uriBuilder.queryParam(key, URLEncoder.encode(params.getFirst(key), StandardCharsets.UTF_8)); } } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java index 2bfa767d4c..ab8e6c91eb 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionServiceTest.java @@ -3,6 +3,8 @@ package com.appsmith.server.services; import com.appsmith.external.models.ActionConfiguration; import com.appsmith.external.models.ActionExecutionResult; import com.appsmith.external.models.Property; +import com.appsmith.external.pluginExceptions.AppsmithPluginError; +import com.appsmith.external.pluginExceptions.AppsmithPluginException; import com.appsmith.external.plugins.PluginExecutor; import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Action; @@ -301,6 +303,39 @@ public class ActionServiceTest { .verifyComplete(); } + @Test + @WithUserDetails(value = "api_user") + public void testActionExecuteErrorResponse() { + ActionExecutionResult mockResult = new ActionExecutionResult(); + mockResult.setIsExecutionSuccess(true); + mockResult.setBody("response-body"); + + Action action = new Action(); + ActionConfiguration actionConfiguration = new ActionConfiguration(); + actionConfiguration.setHeaders(List.of( + new Property("random-header-key", "random-header-value"), + new Property("", "") + )); + action.setActionConfiguration(actionConfiguration); + + ExecuteActionDTO executeActionDTO = new ExecuteActionDTO(); + executeActionDTO.setAction(action); + + AppsmithPluginException pluginException = new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR); + Mockito.when(pluginExecutorHelper.getPluginExecutor(Mockito.any())).thenReturn(Mono.just(pluginExecutor)); + Mockito.when(pluginExecutor.execute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(Mono.error(pluginException)); + Mockito.when(pluginExecutor.datasourceCreate(Mockito.any())).thenReturn(Mono.empty()); + + Mono executionResultMono = actionService.executeAction(executeActionDTO); + + StepVerifier.create(executionResultMono) + .assertNext(result -> { + assertThat(result.getIsExecutionSuccess()).isFalse(); + assertThat(result.getStatusCode()).isEqualTo(pluginException.getAppErrorCode().toString()); + }) + .verifyComplete(); + } + private void executeAndAssertAction(ExecuteActionDTO executeActionDTO, ActionConfiguration actionConfiguration, ActionExecutionResult mockResult) { Mono actionExecutionResultMono = executeAction(executeActionDTO, actionConfiguration, mockResult);