Skip to content

Commit b63baef

Browse files
Disallow missing events in UNTIL
1 parent db53b05 commit b63baef

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/parser/LogicalPlanBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ public Sequence visitSequence(SequenceContext ctx) {
334334
throw new ParsingException(source, "A sequence requires a minimum of 2 queries (excluding UNTIL clause), found [1]");
335335
}
336336
until = queries.remove(queries.size() - 1);
337+
if (until.isMissingEventFilter()) {
338+
throw new ParsingException(source, "UNTIL clause cannot be a negative clause (missing event)");
339+
}
337340
} else {
338341
until = defaultUntil(source);
339342
}

x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/planner/QueryTranslatorFailTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ public void testSequenceWithTooLittleQueriesWithUntil() throws Exception {
267267
plan("sequence [any where true] [any where true] until [any where true]");
268268
}
269269

270+
public void testSequenceWithNegativeUntil() throws Exception {
271+
String s = errorParsing("sequence [any where true] [any where true] until ![any where true]");
272+
assertEquals("1:2: UNTIL clause cannot be a negative clause (missing event)", s);
273+
}
274+
270275
public void testSequenceWithIncorrectOption() throws Exception {
271276
EqlClientException e = expectThrows(EqlClientException.class, () -> plan("sequence [any where true] with repeat=123"));
272277
String msg = e.getMessage();

0 commit comments

Comments
 (0)