Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Heng Qian <qianheng@amazon.com>
  • Loading branch information
qianheng-aws committed Sep 29, 2024
1 parent 0c142be commit 5ed75f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/opensearch/agent/tools/LogPatternTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
public class LogPatternTool extends AbstractRetrieverTool {
public static final String TYPE = "LogPatternTool";

public static String DEFAULT_DESCRIPTION = "Log Pattern Tool";
public static final String DEFAULT_DESCRIPTION = "Log Pattern Tool";
public static final String TOP_N_PATTERN = "top_n_pattern";
public static final String SAMPLE_LOG_SIZE = "sample_log_size";
public static final String PATTERN_FIELD = "pattern_field";
Expand Down Expand Up @@ -119,6 +119,7 @@ public <T> void run(Map<String, String> parameters, ActionListener<T> listener)
: findLongestField(hits[0].getSourceAsMap());
if (patternField == null) {
listener.onResponse((T) "Pattern field is not set and this index doesn't contain any string field");
return;
}
Map<String, List<Map<String, Object>>> patternGroups = new HashMap<>();
for (SearchHit hit : hits) {
Expand Down Expand Up @@ -235,7 +236,7 @@ private static int getInteger(Map<String, ?> params, String paramName) {
}

private static void checkPositive(int value, String paramName) {
if (value < 0) {
if (value <= 0) {
throw new IllegalArgumentException(
LoggerMessageFormat.format("Invalid value {} for parameter {}, it should be positive", value, paramName)
);
Expand Down

0 comments on commit 5ed75f0

Please sign in to comment.