diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java b/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java index 5519529c9..8c986fd3a 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java @@ -228,7 +228,7 @@ private void onAutoCorrelations(Detector detector, Finding finding, Map hits = response.getHits().iterator(); diff --git a/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java b/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java index db0a44e56..bcfc7405e 100644 --- a/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java +++ b/src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java @@ -81,7 +81,7 @@ public void insertCorrelatedFindings(String detectorType, Finding finding, Strin @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - correlateFindingAction.onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + correlateFindingAction.onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } Map hitSource = response.getHits().getHits()[0].getSourceAsMap(); @@ -249,7 +249,7 @@ public void insertOrphanFindings(String detectorType, Finding finding, float tim @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - correlateFindingAction.onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + correlateFindingAction.onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } try { @@ -425,7 +425,7 @@ public void onFailure(Exception e) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - correlateFindingAction.onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + correlateFindingAction.onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } long totalHits = response.getHits().getTotalHits().value; diff --git a/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java b/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java index 488fd14eb..fe1402e59 100644 --- a/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java +++ b/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java @@ -276,7 +276,7 @@ private void doIndexLogTypeMetadata(ActionListener listener) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - listener.onFailure(new OpenSearchStatusException("Unknown error", RestStatus.REQUEST_TIMEOUT)); + listener.onFailure(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } if (response.getHits().getTotalHits().value > 0) { listener.onResponse(null); diff --git a/src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java b/src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java index a4ba93d17..974b76f72 100644 --- a/src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java @@ -81,7 +81,7 @@ private RestResponseListener searchRuleResponse(RestChannel chan @Override public RestResponse buildResponse(SearchResponse response) throws Exception { if (response.isTimedOut()) { - return new BytesRestResponse(RestStatus.REQUEST_TIMEOUT, response.toString()); + return new BytesRestResponse(RestStatus.REQUEST_TIMEOUT, "Search request timed out"); } try { diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java index 9ddb74a49..ecbff7655 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java @@ -223,7 +223,7 @@ void start() { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } SearchHits hits = response.getHits(); @@ -336,7 +336,7 @@ public void onResponse(IndexResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } SearchHit[] hits = response.getHits().getHits(); @@ -392,7 +392,7 @@ public void onFailure(Exception e) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } SearchHit[] hits = response.getHits().getHits(); diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java index 75987d0ce..b93fbf7ad 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java @@ -65,7 +65,7 @@ public void onResponse(BulkByScrollResponse response) { new OpenSearchStatusException( String.format( Locale.getDefault(), - "Correlation Rule with id %s cannot be deleted", + "Search request timed out. Correlation Rule with id %s cannot be deleted", correlationRuleId ), RestStatus.REQUEST_TIMEOUT) diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java index 7bb8de981..a972869c7 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java @@ -174,7 +174,7 @@ private void onGetResponse(CustomLogType logType) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); return; } @@ -187,7 +187,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java index 15b0c0836..6cbb6466b 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java @@ -152,7 +152,7 @@ private void onGetResponse(Rule rule) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", rule.getId()), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Rule with id %s cannot be deleted", rule.getId()), RestStatus.REQUEST_TIMEOUT)); return; } @@ -231,7 +231,7 @@ private void deleteRule(String ruleId) { @Override public void onResponse(BulkByScrollResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", ruleId), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Rule with id %s cannot be deleted", ruleId), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java index 961dbb0c0..cf296a96c 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java @@ -218,12 +218,12 @@ private void prepareCustomLogTypeIndexing() throws IOException { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } if (response.getHits().getTotalHits().value != 1) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.INTERNAL_SERVER_ERROR)); return; } @@ -243,7 +243,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } @@ -256,7 +256,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } @@ -379,7 +379,7 @@ public void onResponse(Void unused) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); return; } @@ -399,7 +399,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java index 50fcc187b..bddd8b46a 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java @@ -1237,7 +1237,7 @@ public void onFailure(Exception e) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } long count = response.getHits().getTotalHits().value; @@ -1302,7 +1302,7 @@ public void importRules(IndexDetectorRequest request, ActionListener ruleFieldMappings) throws IOExcept @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be updated", rule.getId()), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Search request timed out. Rule with id %s cannot be updated", rule.getId()), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java index a0bc5b8bb..da2d7b5bb 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java @@ -119,7 +119,7 @@ void start() { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + onFailures(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } Map correlatedFindings = new HashMap<>(); diff --git a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java index f6ef26e44..a2c2be7ee 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java +++ b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java @@ -328,7 +328,7 @@ public void onResponse(Void unused) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - listener.onFailure(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); + listener.onFailure(new OpenSearchStatusException("Search request timed out", RestStatus.REQUEST_TIMEOUT)); } try { SearchHit[] hits = response.getHits().getHits();