Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/132638.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 132638
summary: Better error message for sequences with only one clause plus UNTIL
area: EQL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,13 @@ public Sequence visitSequence(SequenceContext ctx) {

// until is already parsed through sequenceTerm() above
if (ctx.until != null) {
if (queries.size() == 2) {
throw new ParsingException(source, "A sequence requires a minimum of 2 queries (excluding UNTIL clause), found [1]");
}
until = queries.remove(queries.size() - 1);
if (until.isMissingEventFilter()) {
throw new ParsingException(source, "UNTIL clause cannot be a negative clause (missing event)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct ParsingException would have been ParsingException(until.source(), "UNTIL clause cannot be a....

}
} else {
until = defaultUntil(source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ public void testSequenceWithTooLittleQueries() throws Exception {
assertEquals("1:2: A sequence requires a minimum of 2 queries, found [1]", s);
}

public void testSequenceWithTooLittleQueriesWithUntil() throws Exception {
String s = errorParsing("sequence [any where true] until [any where true]");
assertEquals("1:2: A sequence requires a minimum of 2 queries (excluding UNTIL clause), found [1]", s);
plan("sequence [any where true] [any where true] until [any where true]");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this query as a test, as well: sequence with maxspan=1h ![process where true] until [process where true]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @astefan!
I added that test and opened an issue for missing events in UNTIL #132787

public void testSequenceWithNegativeUntil() throws Exception {
String s = errorParsing("sequence [any where true] [any where true] until ![any where true]");
assertEquals("1:2: UNTIL clause cannot be a negative clause (missing event)", s);
}

public void testSequenceWithIncorrectOption() throws Exception {
EqlClientException e = expectThrows(EqlClientException.class, () -> plan("sequence [any where true] with repeat=123"));
String msg = e.getMessage();
Expand Down