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 3b981bcf20..84c3a96712 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 1fc25d7369..c6cc7efa8b 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 8582cb1dd3..677c821503 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);