Skip to content

Commit

Permalink
updated failure message
Browse files Browse the repository at this point in the history
Signed-off-by: jowg-amazon <[email protected]>
  • Loading branch information
jowg-amazon committed Oct 4, 2023
1 parent e89d643 commit 389cc2b
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private void onAutoCorrelations(Detector detector, Finding finding, Map<String,
@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));

Check warning on line 231 in src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/correlation/JoinEngine.java#L231

Added line #L231 was not covered by tests
}

Iterator<SearchHit> hits = response.getHits().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 84 in src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java#L84

Added line #L84 was not covered by tests
}

Map<String, Object> hitSource = response.getHits().getHits()[0].getSourceAsMap();
Expand Down Expand Up @@ -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));

Check warning on line 252 in src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java#L252

Added line #L252 was not covered by tests
}

try {
Expand Down Expand Up @@ -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));

Check warning on line 428 in src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/correlation/VectorEmbeddingsEngine.java#L428

Added line #L428 was not covered by tests
}

long totalHits = response.getHits().getTotalHits().value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void doIndexLogTypeMetadata(ActionListener<Void> 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));

Check warning on line 279 in src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java#L279

Added line #L279 was not covered by tests
}
if (response.getHits().getTotalHits().value > 0) {
listener.onResponse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private RestResponseListener<SearchResponse> 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");

Check warning on line 84 in src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/resthandler/RestSearchRuleAction.java#L84

Added line #L84 was not covered by tests
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 226 in src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java#L226

Added line #L226 was not covered by tests
}

SearchHits hits = response.getHits();
Expand Down Expand Up @@ -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));

Check warning on line 339 in src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java#L339

Added line #L339 was not covered by tests
}

SearchHit[] hits = response.getHits().getHits();
Expand Down Expand Up @@ -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));

Check warning on line 395 in src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java#L395

Added line #L395 was not covered by tests
}

SearchHit[] hits = response.getHits().getHits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 177 in src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java#L177

Added line #L177 was not covered by tests
return;
}

Expand All @@ -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));

Check warning on line 190 in src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java#L190

Added line #L190 was not covered by tests
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 155 in src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java#L155

Added line #L155 was not covered by tests
return;
}

Expand Down Expand Up @@ -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));

Check warning on line 234 in src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java#L234

Added line #L234 was not covered by tests
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 221 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java#L221

Added line #L221 was not covered by tests
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;
}

Expand All @@ -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));

Check warning on line 246 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java#L246

Added line #L246 was not covered by tests
return;
}

Expand All @@ -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));

Check warning on line 259 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java#L259

Added line #L259 was not covered by tests
return;
}

Expand Down Expand Up @@ -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));

Check warning on line 382 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java#L382

Added line #L382 was not covered by tests
return;
}

Expand All @@ -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));

Check warning on line 402 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java#L402

Added line #L402 was not covered by tests
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 1240 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java#L1240

Added line #L1240 was not covered by tests
}

long count = response.getHits().getTotalHits().value;
Expand Down Expand Up @@ -1302,7 +1302,7 @@ public void importRules(IndexDetectorRequest request, ActionListener<List<IndexM
@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));

Check warning on line 1305 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java#L1305

Added line #L1305 was not covered by tests
}

SearchHits hits = response.getHits();
Expand Down Expand Up @@ -1362,7 +1362,7 @@ public void importCustomRules(Detector detector, DetectorInput detectorInput, Li
@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));

Check warning on line 1365 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexDetectorAction.java#L1365

Added line #L1365 was not covered by tests
}

SearchHits hits = response.getHits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void indexRule(Rule rule, Map<String, String> 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));

Check warning on line 240 in src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java#L240

Added line #L240 was not covered by tests
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 122 in src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/transport/TransportListCorrelationAction.java#L122

Added line #L122 was not covered by tests
}

Map<String, CorrelatedFinding> correlatedFindings = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Check warning on line 331 in src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java#L331

Added line #L331 was not covered by tests
}
try {
SearchHit[] hits = response.getHits().getHits();
Expand Down

0 comments on commit 389cc2b

Please sign in to comment.