Skip to content

EQL: better error message for sequences with only one clause plus UNTIL #132638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all 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,6 +330,9 @@ 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);
} 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 testSequenceWithOnlyMissingEventsAndUntil() throws Exception {
String s = errorParsing("sequence with maxspan=1h ![process where true] until [process where true]");
assertEquals("1:2: A sequence requires a minimum of 2 queries (excluding UNTIL clause), found [1]", 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