diff --git a/common/src/main/java/org/opensearch/ml/common/CommonValue.java b/common/src/main/java/org/opensearch/ml/common/CommonValue.java index dab60ce986..483c9238e4 100644 --- a/common/src/main/java/org/opensearch/ml/common/CommonValue.java +++ b/common/src/main/java/org/opensearch/ml/common/CommonValue.java @@ -18,6 +18,7 @@ public class CommonValue { public static Integer NO_SCHEMA_VERSION = 0; + public static final String REMOTE_SERVICE_ERROR = "Error from remote service: "; public static final String USER = "user"; public static final String META = "_meta"; public static final String SCHEMA_VERSION_FIELD = "schema_version"; diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/AwsConnectorExecutor.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/AwsConnectorExecutor.java index c924808f5c..eced029e1c 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/AwsConnectorExecutor.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/AwsConnectorExecutor.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Map; +import static org.opensearch.ml.common.CommonValue.REMOTE_SERVICE_ERROR; import static org.opensearch.ml.common.connector.ConnectorProtocols.AWS_SIGV4; import static org.opensearch.ml.engine.algorithms.remote.ConnectorUtils.processOutput; import static software.amazon.awssdk.http.SdkHttpMethod.POST; @@ -102,7 +103,7 @@ public void invokeRemoteModel(MLInput mlInput, Map parameters, S } String modelResponse = responseBuilder.toString(); if (statusCode < 200 || statusCode >= 300) { - throw new OpenSearchStatusException(modelResponse, RestStatus.fromCode(statusCode)); + throw new OpenSearchStatusException(REMOTE_SERVICE_ERROR + modelResponse, RestStatus.fromCode(statusCode)); } ModelTensors tensors = processOutput(modelResponse, connector, scriptService, parameters); diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutor.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutor.java index 1a993b88d2..d6fce16732 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutor.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutor.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicReference; +import static org.opensearch.ml.common.CommonValue.REMOTE_SERVICE_ERROR; import static org.opensearch.ml.common.connector.ConnectorProtocols.HTTP; import static org.opensearch.ml.engine.algorithms.remote.ConnectorUtils.processOutput; @@ -107,7 +108,7 @@ public void invokeRemoteModel(MLInput mlInput, Map parameters, S String modelResponse = responseRef.get(); Integer statusCode = statusCodeRef.get(); if (statusCode < 200 || statusCode >= 300) { - throw new OpenSearchStatusException(modelResponse, RestStatus.fromCode(statusCode)); + throw new OpenSearchStatusException(REMOTE_SERVICE_ERROR + modelResponse, RestStatus.fromCode(statusCode)); } ModelTensors tensors = processOutput(modelResponse, connector, scriptService, parameters);