fix(cloudwatch): warn on unsupported Logs Insights filter operators (#2170)

parseFilter scans for the leftmost '!=', '==' or '=' outside a quoted
value, so the '=' inside '>=', '<=' and '=~' won. For '>=' and '<=' the
comparison character was absorbed into the field name ("@message >"),
which resolves to null for every row, and passesFilters treats null as
non-matching; for '=~' the value became the literal "~ /ERROR/". Either
way the query came back with no rows and no warning, because as far as
parseFilter was concerned it had found a valid operator.

Stop the scan when a position starts one of those three operators, so
control reaches the "Ignoring unsupported Logs Insights filter" warning
that '<', '>', 'like', 'not like' and 'in' already hit, and the stage is
dropped instead. Quote tracking is untouched, so a '>=' inside a quoted
value is still just part of the value.

The docs table describing how unsupported syntax degrades had the same
two cases inverted: '=~' listed as warn-and-drop when it mis-parsed, and
bare '<' / '>' as silent-zero-rows when they already warned. Folded into
the one row that now matches the code, and the compound and/or mis-parse
this change does not fix got its own row instead of staying implied.

Refs #2042
This commit is contained in:
soreavis authored and GitHub committed 2026-08-12 10:52:24 -04:00
1 parent 819bfedc6c
commit f1c81977ec
3 files changed
+57 -6

No files matched your search

@@ -30,8 +30,9 @@ import java.util.Set;
* {@code @ptr}, or a dotted path into the JSON log message (e.g. {@code params.job_id}, {@code level}).
*
* <p>This is intentionally <em>not</em> a full Insights implementation: unsupported commands
* (e.g. {@code stats}, {@code parse}) are ignored with a warning. Pipes ({@code |}) inside quoted
* filter values are respected and do not split the query into stages.
* (e.g. {@code stats}, {@code parse}) and unsupported filter operators (e.g. {@code >=},
* {@code like}) are ignored with a warning. Pipes ({@code |}) inside quoted filter values are
* respected and do not split the query into stages.
*/
final class LogsInsightsQuery {
@@ -154,6 +155,10 @@ final class LogsInsightsQuery {
}
} else if (c == '\'' || c == '"') {
quote = c;
} else if (expr.startsWith(">=", i) || expr.startsWith("<=", i) || expr.startsWith("=~", i)) {
// The '=' in >=, <= and =~ would be read as equality below, mangling the field
// (>=, <=) or the value (=~) into a dead match; stop so they warn instead.
break;
} else if (i > 0) {
String op = expr.startsWith("!=", i) ? "!="
: expr.startsWith("==", i) ? "=="