crbench//

← all cases

chore: recognize variable in expression

Tier 2 hard go · local · real merged PR from SigNoz/signoz #8328

Ground-truth defects

d1 · performance · high
In pkg/querier/postprocess.go the new prepareFillZeroArgsWithStep builds the fillZero function args as {req.Start, req.End, step} where step is computed in milliseconds (query.StepInterval.Duration.Milliseconds()) but req.Start/req.End are not guaranteed to be in milliseconds at runtime (callers may pass nanosecond-resolution timestamps). funcFillZero requires all three args in the same unit and loops from start to end by step appending one point per iteration; when start/end are nanoseconds and step is milliseconds the iteration count is ~10^6x too large, so the fill-zero path allocates an enormous slice of zero points and blows up memory / OOMs the query service.
d2 · correctness · high
In pkg/querybuilder/where_clause_visitor.go the new variable-recognition blocks in VisitComparison slice var_ with var_[1:] (to retry the variable lookup without a leading '$') guarded only by a string type assertion: "if var_, ok := value.(string); ok" / "if var_, ok := values[0].(string); ok". An empty string passes that assertion, and var_[1:] on "" panics with "slice bounds out of range [1:0]", crashing the request goroutine / query service. It is reachable: a filter expression value of '' (empty quoted literal) flows through VisitValue -> trimQuotes("''") -> "" into both the single-value comparison path and the IN/NOT IN path.
d3 · correctness · high
In pkg/querier/clickhouse_query.go the new renderVars builds substitution data with "varsData[k] = formatValueForCH(v)" where v is a qbtypes.VariableItem struct, not its underlying value. formatValueForCH(v any) has no case for the VariableItem struct type, so every user variable falls through to the default branch and renders to the empty string "". The empty string is then substituted into the raw ClickHouse query via strings.Replace for $var / {{var}} / [[var]] placeholders, producing malformed SQL (e.g. "WHERE service_name = " with no operand) or a silently wrong filter for every custom variable. The same defect was shipped on the PromQL path with formatValueForProm(v).
d4 · correctness · high
In VisitComparison's scalar-comparison branch, `case []any: value = varValues[0]` indexes into a variable's resolved slice value with no length check. A QueryRangeRequest whose variable resolves to an empty slice (e.g. {"variables":{"myVar":{"value":[]}}}) used in a simple comparison like `service_name = $myVar` panics with an index-out-of-range, crashing the request goroutine (recovered by api.go into an HTTP 500). The sibling IN-clause branch a few lines away does the analogous assignment without indexing (values = varValues), so it doesn't share this exact crash but has its own bug (see d5).
d5 · correctness · medium
In VisitComparison's IN-clause branch, `case []any: values = varValues` passes an empty slice straight through when a variable resolves to []any{}. condition_builder.go's FilterOperatorIn handler then builds conditions := []string{} from an empty values, and sb.Or(conditions...) with zero arguments returns an empty string (confirmed in the vendored huandu/go-sqlbuilder@v1.35.0 source: Or returns "" when len(orExpr) == 0 after filtering). The generated WHERE-clause fragment for that condition vanishes rather than encoding "no rows match", so a filter meant to exclude everything silently matches all rows instead.
d6 · security · medium
chSQLQuery.renderVars substitutes variable values into the raw ClickHouse query string via strings.Replace BEFORE parsing that string as a Go text/template (tmpl.Parse(query) / tmpl.Execute). If a variable's own VALUE contains the Go template delimiters {{/}}, the substituted text is then re-interpreted as a live template action in the second stage -- e.g. a variable value of "{{.SIGNOZ_START_TIME}}" gets replaced with the numeric start timestamp rather than being treated as literal text, silently changing the rendered query; a malformed template fragment (e.g. "{{.") causes template.Parse to fail, surfacing as an opaque HTTP 500.
d7 · correctness · medium
parseFieldKeyRequest renames the field-key search parameter from ?name to ?searchText (r.URL.Query().Get("name") -> r.URL.Query().Get("searchText")). parseFieldValueRequest calls parseFieldKeyRequest internally (now reading ?searchText) and separately reads ?name for a different purpose (keySelector.Name, overriding what the key-request set). Any existing caller using GET /api/v1/fields?name=service_name to filter the field-key list gets back all keys instead of a filtered set -- the ?name parameter is simply ignored for that endpoint, a breaking API change with no version bump.
d8 · correctness · medium
rewriteExpression replaces all quoted string literals in the HAVING expression with __QUOTED_N__ placeholders BEFORE matching column-map keys against it. A key like countIf(level='error') (itself containing a quoted literal) is turned into a regex built from its raw, unprotected form, so it can never match the already-placeholder-substituted expression -- e.g. a HAVING clause countIf(level='error') > 10 reads as countIf(level=__QUOTED_0__) > 10 after quote-protection, and the \bcountIf\(level='error'\) pattern silently fails to match, so the rewrite (and the __result_N substitution downstream code depends on) is silently skipped.
d9 · correctness · high
`renderVars` iterates `vars map[string]qbv5.VariableItem` and passes the struct itself to `formatValueForProm(v any)`. `VariableItem` is a struct of `{Type, Value}`, and the type switch handles only int, float32/64, string, bool and []interface{}, so every variable falls through to `default: return ""`. Every user-defined variable in a custom PromQL query is silently replaced with the empty string; the call should pass `v.Value`.

The change under review

diff (truncated — full diff)
diff --git a/ee/query-service/app/api/api.go b/ee/query-service/app/api/api.go
index 9fbd859bd59..5003993ee27 100644
--- a/ee/query-service/app/api/api.go
+++ b/ee/query-service/app/api/api.go
@@ -59,7 +59,7 @@ func NewAPIHandler(opts APIHandlerOptions, signoz *signoz.SigNoz) (*APIHandler,
 		LicensingAPI:                  httplicensing.NewLicensingAPI(signoz.Licensing),
 		FieldsAPI:                     fields.NewAPI(signoz.Instrumentation.ToProviderSettings(), signoz.TelemetryStore),
 		Signoz:                        signoz,
-		QuerierAPI:                    querierAPI.NewAPI(signoz.Querier),
+		QuerierAPI:                    querierAPI.NewAPI(signoz.Instrumentation.ToProviderSettings(), signoz.Querier),
 	})
 
 	if err != nil {
diff --git a/grammar/FilterQuery.g4 b/grammar/FilterQuery.g4
index 507689754ac..9b84cbd0e20 100644
--- a/grammar/FilterQuery.g4
+++ b/grammar/FilterQuery.g4
@@ -79,11 +79,13 @@ comparison
 inClause
     : IN LPAREN valueList RPAREN
     | IN LBRACK valueList RBRACK
+    | IN value
     ;
 
 notInClause
     : NOT IN LPAREN valueList RPAREN
     | NOT IN LBRACK valueList RBRACK
+    | NOT IN value
     ;
 
 // List of values for in(...) or in[...]
@@ -206,7 +208,7 @@ QUOTED_TEXT
         )
     ;
 
-fragment SEGMENT      : [a-zA-Z] [a-zA-Z0-9_:\-]* ;
+fragment SEGMENT      : [a-zA-Z$] [a-zA-Z0-9$_:\-]* ;
 fragment EMPTY_BRACKS : '[' ']' ;
 fragment OLD_JSON_BRACKS: '[' '*' ']';
 
diff --git a/pkg/apis/fields/parse.go b/pkg/apis/fields/parse.go
index 7ca1b5a5ae2..114be5a5166 100644
--- a/pkg/apis/fields/parse.go
+++ b/pkg/apis/fields/parse.go
@@ -70,7 +70,7 @@ func parseFieldKeyRequest(r *http.Request) (*telemetrytypes.FieldKeySelector, er
 		}
 	}
 
-	name := r.URL.Query().Get("name")
+	name := r.URL.Query().Get("searchText")
 
 	req = telemetrytypes.FieldKeySelector{
 		StartUnixMilli:    startUnixMilli,
@@ -92,8 +92,10 @@ func parseFieldValueRequest(r *http.Request) (*telemetrytypes.FieldValueSelector
 		return nil, errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, "failed to parse field key request")
 	}
 
+	name := r.URL.Query().Get("name")
+	keySelector.Name = name
 	existingQuery := r.URL.Query().Get("existingQuery")
-	value := r.URL.Query().Get("value")
+	value := r.URL.Query().Get("searchText")
 
 	// Parse limit for fieldValue request, fallback to default 50 if parsing fails.
 	limit, err := strconv.Atoi(r.URL.Query().Get("limit"))
diff --git a/pkg/parser/grammar/FilterQuery.interp b/pkg/parser/grammar/FilterQuery.interp
index b78a05c21ac..70b418eb48b 100644
--- a/pkg/parser/grammar/FilterQuery.interp
+++ b/pkg/parser/grammar/FilterQuery.interp
@@ -91,4 +91,4 @@ key
 
 
 atn:
-[4, 1, 33, 213, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43, 8, 2, 10, 2, 12, 2, 46, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 52, 8, 3, 10, 3, 12, 3, 55, 9, 3, 1, 4, 3, 4, 58, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 71, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 149, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 161, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 175, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 180, 8, 9, 10, 9, 12, 9, 183, 9, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 195, 8, 12, 10, 12, 12, 12, 198, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 203, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 1, 0, 7, 8, 2, 0, 13, 13, 15, 15, 2, 0, 14, 14, 16, 16, 2, 0, 30, 30, 33, 33, 1, 0, 25, 27, 1, 0, 28, 31, 227, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 47, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 160, 1, 0, 0, 0, 16, 174, 1, 0, 0, 0, 18, 176, 1, 0, 0, 0, 20, 184, 1, 0, 0, 0, 22, 186, 1, 0, 0, 0, 24, 191, 1, 0, 0, 0, 26, 202, 1, 0, 0, 0, 28, 204, 1, 0, 0, 0, 30, 208, 1, 0, 0, 0, 32, 210, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 3, 4, 2, 0, 38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 24, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 53, 3, 8, 4, 0, 48, 49, 5, 23, 0, 0, 49, 52, 3, 8, 4, 0, 50, 52, 3, 8, 4, 0, 51, 48, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 56, 58, 5, 22, 0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61, 62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0, 0, 65, 71, 3, 12, 6, 0, 66, 71, 3, 22, 11, 0, 67, 71, 3, 20, 10, 0, 68, 71, 3, 32, 16, 0, 69, 71, 3, 30, 15, 0, 70, 61, 1, 0, 0, 0, 70, 65, 1, 0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 73, 3, 32, 16, 0, 73, 74, 5, 6, 0, 0, 74, 75, 3, 30, 15, 0, 75, 149, 1, 0, 0, 0, 76, 77, 3, 32, 16, 0, 77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15, 0, 79, 149, 1, 0, 0, 0, 80, 81, 3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83, 3, 30, 15, 0, 83, 149, 1, 0, 0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10, 0, 0, 86, 87, 3, 30, 15, 0, 87, 149, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0, 89, 90, 5, 11, 0, 0, 90, 91, 3, 30, 15, 0, 91, 149, 1, 0, 0, 0, 92, 93, 3, 32, 16, 0, 93, 94, 5, 12, 0, 0, 94, 95, 3, 30, 15, 0, 95, 149, 1, 0, 0, 0, 96, 97, 3, 32, 16, 0, 97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99, 149, 1, 0, 0, 0, 100, 101, 3, 32, 16, 0, 101, 102, 7, 2, 0, 0, 102, 103, 3, 30, 15, 0, 103, 149, 1, 0, 0, 0, 104, 105, 3, 32, 16, 0, 105, 106, 5, 17, 0, 0, 106, 107, 3, 30, 15, 0, 107, 108, 5, 23, 0, 0, 108, 109, 3, 30, 15, 0, 109, 149, 1, 0, 0, 0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 22, 0, 0, 112, 113, 5, 17, 0, 0, 113, 114, 3, 30, 15, 0, 114, 115, 5, 23, 0, 0, 115, 116, 3, 30, 15, 0, 116, 149, 1, 0, 0, 0, 117, 118, 3, 32, 16, 0, 118, 119, 3, 14, 7, 0, 119, 149, 1, 0, 0, 0, 120, 121, 3, 32, 16, 0, 121, 122, 3, 16, 8, 0, 122, 149, 1, 0, 0, 0, 123, 124, 3, 32, 16, 0, 124, 125, 5, 18, 0, 0, 125, 149, 1, 0, 0, 0, 126, 127, 3, 32, 16, 0, 127, 128, 5, 22, 0, 0, 128, 129, 5, 18, 0, 0, 129, 149, 1, 0, 0, 0, 130, 131, 3, 32, 16, 0, 131, 132, 5, 19, 0, 0, 132, 133, 3, 30, 15, 0, 133, 149, 1, 0, 0, 0, 134, 135, 3, 32, 16, 0, 135, 136, 5, 22, 0, 0, 136, 137, 5, 19, 0, 0, 137, 138, 3, 30, 15, 0, 138, 149, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 141, 5, 20, 0, 0, 141, 142, 3, 30, 15, 0, 142, 149, 1, 0, 0, 0, 143, 144, 3, 32, 16, 0, 144, 145, 5, 22, 0, 0, 145, 146, 5, 20, 0, 0, 146, 147, 3, 30, 15, 0, 147, 149, 1, 0, 0, 0, 148, 72, 1, 0, 0, 0, 148, 76, 1, 0, 0, 0, 148, 80, 1, 0, 0, 0, 148, 84, 1, 0, 0, 0, 148, 88, 1, 0, 0, 0, 148, 92, 1, 0, 0, 0, 148, 96, 1, 0, 0, 0, 148, 100, 1, 0, 0, 0, 148, 104, 1, 0, 0, 0, 148, 110, 1, 0, 0, 0, 148, 117, 1, 0, 0, 0, 148, 120, 1, 0, 0, 0, 148, 123, 1, 0, 0, 0, 148, 126, 1, 0, 0, 0, 148, 130, 1, 0, 0, 0, 148, 134, 1, 0, 0, 0, 148, 139, 1, 0, 0, 0, 148, 143, 1, 0, 0, 0, 149, 13, 1, 0, 0, 0, 150, 151, 5, 21, 0, 0, 151, 152, 5, 1, 0, 0, 152, 153, 3, 18, 9, 0, 153, 154, 5, 2, 0, 0, 154, 161, 1, 0, 0, 0, 155, 156, 5, 21, 0, 0, 156, 157, 5, 3, 0, 0, 157, 158, 3, 18, 9, 0, 158, 159, 5, 4, 0, 0, 159, 161, 1, 0, 0, 0, 160, 150, 1, 0, 0, 0, 160, 155, 1, 0, 0, 0, 161, 15, 1, 0, 0, 0, 162, 163, 5, 22, 0, 0, 163, 164, 5, 21, 0, 0, 164, 165, 5, 1, 0, 0, 165, 166, 3, 18, 9, 0, 166, 167, 5, 2, 0, 0, 167, 175, 1, 0, 0, 0, 168, 169, 5, 22, 0, 0, 169, 170, 5, 21, 0, 0, 170, 171, 5, 3, 0, 0, 171, 172, 3, 18, 9, 0, 172, 173, 5, 4, 0, 0, 173, 175, 1, 0, 0, 0, 174, 162, 1, 0, 0, 0, 174, 168, 1, 0, 0, 0, 175, 17, 1, 0, 0, 0, 176, 181, 3, 30, 15, 0, 177, 178, 5, 5, 0, 0, 178, 180, 3, 30, 15, 0, 179, 177, 1, 0, 0, 0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 19, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 185, 7, 3, 0, 0, 185, 21, 1, 0, 0, 0, 186, 187, 7, 4, 0, 0, 187, 188, 5, 1, 0, 0, 188, 189, 3, 24, 12, 0, 189, 190, 5, 2, 0, 0, 190, 23, 1, 0, 0, 0, 191, 196, 3, 26, 13, 0, 192, 193, 5, 5, 0, 0, 193, 195, 3, 26, 13, 0, 194, 192, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 25, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 203, 3, 32, 16, 0, 200, 203, 3, 30, 15, 0, 201, 203, 3, 28, 14, 0, 202, 199, 1, 0, 0, 0, 202, 200, 1, 0, 0, 0, 202, 201, 1, 0, 0, 0, 203, 27, 1, 0, 0, 0, 204, 205, 5, 3, 0, 0, 205, 206, 3, 18, 9, 0, 206, 207, 5, 4, 0, 0, 207, 29, 1, 0, 0, 0, 208, 209, 7, 5, 0, 0, 209, 31, 1, 0, 0, 0, 210, 211, 5, 31, 0, 0, 211, 33, 1, 0, 0, 0, 11, 44, 51, 53, 57, 70, 148, 160, 174, 181, 196, 202]
\ No newline at end of file
+[4, 1, 33, 218, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43, 8, 2, 10, 2, 12, 2, 46, 9, 2, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 52, 8, 3, 10, 3, 12, 3, 55, 9, 3, 1, 4, 3, 4, 58, 8, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 71, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 149, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 163, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 180, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 185, 8, 9, 10, 9, 12, 9, 188, 9, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 200, 8, 12, 10, 12, 12, 12, 203, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 208, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 1, 0, 7, 8, 2, 0, 13, 13, 15, 15, 2, 0, 14, 14, 16, 16, 2, 0, 30, 30, 33, 33, 1, 0, 25, 27, 1, 0, 28, 31, 234, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 47, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 162, 1, 0, 0, 0, 16, 179, 1, 0, 0, 0, 18, 181, 1, 0, 0, 0, 20, 189, 1, 0, 0, 0, 22, 191, 1, 0, 0, 0, 24, 196, 1, 0, 0, 0, 26, 207, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 213, 1, 0, 0, 0, 32, 215, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 3, 4, 2, 0, 38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 24, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 53, 3, 8, 4, 0, 48, 49, 5, 23, 0, 0, 49, 52, 3, 8, 4, 0, 50, 52, 3, 8, 4, 0, 51, 48, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 56, 58, 5, 22, 0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61, 62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0, 0, 65, 71, 3, 12, 6, 0, 66, 71, 3, 22, 11, 0, 67, 71, 3, 20, 10, 0, 68, 71, 3, 32, 16, 0, 69, 71, 3, 30, 15, 0, 70, 61, 1, 0, 0, 0, 70, 65, 1, 0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 73, 3, 32, 16, 0, 73, 74, 5, 6, 0, 0, 74, 75, 3, 30, 15, 0, 75, 149, 1, 0, 0, 0, 76, 77, 3, 32, 16, 0, 77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15, 0, 79, 149, 1, 0, 0, 0, 80, 81, 3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83, 3, 30, 15, 0, 83, 149, 1, 0, 0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10, 0, 0, 86, 87, 3, 30, 15, 0, 87, 149, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0, 89, 90, 5, 11, 0, 0, 90, 91, 3, 30, 15, 0, 91, 149, 1, 0, 0, 0, 92, 93, 3, 32, 16, 0, 93, 94, 5, 12, 0, 0, 94, 95, 3, 30, 15, 0, 95, 149, 1, 0, 0, 0, 96, 97, 3, 32, 16, 0, 97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99, 149, 1, 0, 0, 0, 100, 101, 3, 32, 16, 0, 101, 102, 7, 2, 0, 0, 102, 103, 3, 30, 15, 0, 103, 149, 1, 0, 0, 0, 104, 105, 3, 32, 16, 0, 105, 106, 5, 17, 0, 0, 106, 107, 3, 30, 15, 0, 107, 108, 5, 23, 0, 0, 108, 109, 3, 30, 15, 0, 109, 149, 1, 0, 0, 0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 22, 0, 0, 112, 113, 5, 17, 0, 0, 113, 114, 3, 30, 15, 0, 114, 115, 5, 23, 0, 0, 115, 116, 3, 30, 15, 0, 116, 149, 1, 0, 0, 0, 117, 118, 3, 32, 16, 0, 118, 119, 3, 14, 7, 0, 119, 149, 1, 0, 0, 0, 120, 121, 3, 32, 16, 0, 121, 122, 3, 16, 8, 0, 122, 149, 1, 0, 0, 0, 123, 124, 3, 32, 16, 0, 124, 125, 5, 18, 0, 0, 125, 149, 1, 0, 0, 0, 126, 127, 3, 32, 16, 0, 127, 128, 5, 22, 0, 0, 128, 129, 5, 18, 0, 0, 129, 149, 1, 0, 0, 0, 130, 131, 3, 32, 16, 0, 131, 132, 5, 19, 0, 0, 132, 133, 3, 30, 15, 0, 133, 149, 1, 0, 0, 0, 134, 135, 3, 32, 16, 0, 135, 136, 5, 22, 0, 0, 136, 137, 5, 19, 0, 0, 137, 138, 3, 30, 15, 0, 138, 149, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 141, 5, 20, 0, 0, 141, 142, 3, 30, 15, 0, 142, 149, 1, 0, 0, 0, 143, 144, 3, 32, 16, 0, 144, 145, 5, 22, 0, 0, 145, 146, 5, 20, 0, 0, 146, 147, 3, 30, 15, 0, 147, 149, 1, 0, 0, 0, 148, 72, 1, 0, 0, 0, 148, 76, 1, 0, 0, 0, 148, 80, 1, 0, 0, 0, 148, 84, 1, 0, 0, 0, 148, 88, 1, 0, 0, 0, 148, 92, 1, 0, 0, 0, 148, 96, 1, 0, 0, 0, 148, 100, 1, 0, 0, 0, 148, 104, 1, 0, 0, 0, 148, 110, 1, 0, 0, 0, 148, 117, 1, 0, 0, 0, 148, 120, 1, 0, 0, 0, 148, 123, 1, 0, 0, 0, 148, 126, 1, 0, 0, 0, 148, 130, 1, 0, 0, 0, 148, 134, 1, 0, 0, 0, 148, 139, 1, 0, 0, 0, 148, 143, 1, 0, 0, 0, 149, 13, 1, 0, 0, 0, 150, 151, 5, 21, 0, 0, 151, 152, 5, 1, 0, 0, 152, 153, 3, 18, 9, 0, 153, 154, 5, 2, 0, 0, 154, 163, 1, 0, 0, 0, 155, 156, 5, 21, 0, 0, 156, 157, 5, 3, 0, 0, 157, 158, 3, 18, 9, 0, 158, 159, 5, 4, 0, 0, 159, 163, 1, 0, 0, 0, 160, 161, 5, 21, 0, 0, 161, 163, 3, 30, 15, 0, 162, 150, 1, 0, 0, 0, 162, 155, 1, 0, 0, 0, 162, 160, 1, 0, 0, 0, 163, 15, 1, 0, 0, 0, 164, 165, 5, 22, 0, 0, 165, 166, 5, 21, 0, 0, 166, 167, 5, 1, 0, 0, 167, 168, 3, 18, 9, 0, 168, 169, 5, 2, 0, 0, 169, 180, 1, 0, 0, 0, 170, 171, 5, 22, 0, 0, 171, 172, 5, 21, 0, 0, 172, 173, 5, 3, 0, 0, 173, 174, 3, 18, 9, 0, 174, 175, 5, 4, 0, 0, 175, 180, 1, 0, 0, 0, 176, 177, 5, 22, 0, 0, 177, 178, 5, 21, 0, 0, 178, 180, 3, 30, 15, 0, 179, 164, 1, 0, 0, 0, 179, 170, 1, 0, 0, 0, 179, 176, 1, 0, 0, 0, 180, 17, 1, 0, 0, 0, 181, 186, 3, 30, 15, 0, 182, 183, 5, 5, 0, 0, 183, 185, 3, 30, 15, 0, 184, 182, 1, 0, 0, 0, 185, 188, 1, 0, 0, 0, 186, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 19, 1, 0, 0, 0, 188, 186, 1, 0, 0, 0, 189, 190, 7, 3, 0, 0, 190, 21, 1, 0, 0, 0, 191, 192, 7, 4, 0, 0, 192, 193, 5, 1, 0, 0, 193, 194, 3, 24, 12, 0, 194, 195, 5, 2, 0, 0, 195, 23, 1, 0, 0, 0, 196, 201, 3, 26, 13, 0, 197, 198, 5, 5, 0, 0, 198, 200, 3, 26, 13, 0, 199, 197, 1, 0, 0, 0, 200, 203, 1, 0, 0, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0, 0, 203, 201, 1, 0, 0, 0, 204, 208, 3, 32, 16, 0, 205, 208, 3, 30, 15, 0, 206, 208, 3, 28, 14, 0, 207, 204, 1, 0, 0, 0, 207, 205, 1, 0, 0, 0, 207, 206, 1, 0, 0, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 3, 0, 0, 210, 211, 3, 18, 9, 0, 211, 212, 5, 4, 0, 0, 212, 29, 1, 0, 0, 0, 213, 214, 7, 5, 0, 0, 214, 31, 1, 0, 0, 0, 215, 216, 5, 31, 0, 0, 216, 33, 1, 0, 0, 0, 11, 44, 51, 53, 57, 70, 148, 162, 179, 186, 201, 207]
\ No newline at end of file
diff --git a/pkg/parser/grammar/FilterQueryLexer.interp b/pkg/parser/grammar/FilterQueryLexer.interp
index 888c0b75bab..7c22ebda90b 100644
--- a/pkg/parser/grammar/FilterQueryLexer.interp
+++ b/pkg/parser/grammar/FilterQueryLexer.interp
@@ -118,4 +118,4 @@ mode names:
 DEFAULT_MODE
 
 atn:
-[4, 0, 33, 334, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 91, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 4, 13, 118, 8, 13, 11, 13, 12, 13, 119, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 137, 8, 15, 11, 15, 12, 15, 138, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 161, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 178, 8, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 221, 8, 27, 1, 28, 1, 28, 1, 29, 3, 29, 226, 8, 29, 1, 29, 4, 29, 229, 8, 29, 11, 29, 12, 29, 230, 1, 29, 1, 29, 5, 29, 235, 8, 29, 10, 29, 12, 29, 238, 9, 29, 3, 29, 240, 8, 29, 1, 29, 1, 29, 3, 29, 244, 8, 29, 1, 29, 4, 29, 247, 8, 29, 11, 29, 12, 29, 248, 3, 29, 251, 8, 29, 1, 29, 3, 29, 254, 8, 29, 1, 29, 1, 29, 4, 29, 258, 8, 29, 11, 29, 12, 29, 259, 1, 29, 1, 29, 3, 29, 264, 8, 29, 1, 29, 4, 29, 267, 8, 29, 11, 29, 12, 29, 268, 3, 29, 271, 8, 29, 3, 29, 273, 8, 29, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 279, 8, 30, 10, 30, 12, 30, 282, 9, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 289, 8, 30, 10, 30, 12, 30, 292, 9, 30, 1, 30, 3, 30, 295, 8, 30, 1, 31, 1, 31, 5, 31, 299, 8, 31, 10, 31, 12, 31, 302, 9, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 316, 8, 34, 10, 34, 12, 34, 319, 9, 34, 1, 35, 4, 35, 322, 8, 35, 11, 35, 12, 35, 323, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 4, 37, 331, 8, 37, 11, 37, 12, 37, 332, 0, 0, 38, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 29, 61, 30, 63, 0, 65, 0, 67, 0, 69, 31, 71, 32, 73, 0, 75, 33, 1, 0, 30, 2, 0, 76, 76, 108, 108, 2, 0, 73, 73, 105, 105, 2, 0, 75, 75, 107, 107, 2, 0, 69, 69, 101, 101, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 84, 84, 116, 116, 2, 0, 9, 9, 32, 32, 2, 0, 66, 66, 98, 98, 2, 0, 87, 87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0, 83, 83, 115, 115, 2, 0, 82, 82, 114, 114, 2, 0, 71, 71, 103, 103, 2, 0, 80, 80, 112, 112, 2, 0, 67, 67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100, 2, 0, 72, 72, 104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117, 2, 0, 70, 70, 102, 102, 2, 0, 43, 43, 45, 45, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39, 92, 92, 2, 0, 65, 90, 97, 122, 5, 0, 45, 45, 48, 58, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 8, 0, 9, 10, 13, 13, 32, 34, 39, 41, 44, 44, 60, 62, 91, 91, 93, 93, 358, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 79, 1, 0, 0, 0, 5, 81, 1, 0, 0, 0, 7, 83, 1, 0, 0, 0, 9, 85, 1, 0, 0, 0, 11, 90, 1, 0, 0, 0, 13, 92, 1, 0, 0, 0, 15, 95, 1, 0, 0, 0, 17, 98, 1, 0, 0, 0, 19, 100, 1, 0, 0, 0, 21, 103, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 108, 1, 0, 0, 0, 27, 113, 1, 0, 0, 0, 29, 126, 1, 0, 0, 0, 31, 132, 1, 0, 0, 0, 33, 146, 1, 0, 0, 0, 35, 154, 1, 0, 0, 0, 37, 162, 1, 0, 0, 0, 39, 169, 1, 0, 0, 0, 41, 179, 1, 0, 0, 0, 43, 182, 1, 0, 0, 0, 45, 186, 1, 0, 0, 0, 47, 190, 1, 0, 0, 0, 49, 193, 1, 0, 0, 0, 51, 197, 1, 0, 0, 0, 53, 204, 1, 0, 0, 0, 55, 220, 1, 0, 0, 0, 57, 222, 1, 0, 0, 0, 59, 272, 1, 0, 0, 0, 61, 294, 1, 0, 0, 0, 63, 296, 1, 0, 0, 0, 65, 303, 1, 0, 0, 0, 67, 306, 1, 0, 0, 0, 69, 310, 1, 0, 0, 0, 71, 321, 1, 0, 0, 0, 73, 327, 1, 0, 0, 0, 75, 330, 1, 0, 0, 0, 77, 78, 5, 40, 0, 0, 78, 2, 1, 0, 0, 0, 79, 80, 5, 41, 0, 0, 80, 4, 1, 0, 0, 0, 81, 82, 5, 91, 0, 0, 82, 6, 1, 0, 0, 0, 83, 84, 5, 93, 0, 0, 84, 8, 1, 0, 0, 0, 85, 86, 5, 44, 0, 0, 86, 10, 1, 0, 0, 0, 87, 91, 5, 61, 0, 0, 88, 89, 5, 61, 0, 0, 89, 91, 5, 61, 0, 0, 90, 87, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 12, 1, 0, 0, 0, 92, 93, 5, 33, 0, 0, 93, 94, 5, 61, 0, 0, 94, 14, 1, 0, 0, 0, 95, 96, 5, 60, 0, 0, 96, 97, 5, 62, 0, 0, 97, 16, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 18, 1, 0, 0, 0, 100, 101, 5, 60, 0, 0, 101, 102, 5, 61, 0, 0, 102, 20, 1, 0, 0, 0, 103, 104, 5, 62, 0, 0, 104, 22, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 107, 5, 61, 0, 0, 107, 24, 1, 0, 0, 0, 108, 109, 7, 0, 0, 0, 109, 110, 7, 1, 0, 0, 110, 111, 7, 2, 0, 0, 111, 112, 7, 3, 0, 0, 112, 26, 1, 0, 0, 0, 113, 114, 7, 4, 0, 0, 114, 115, 7, 5, 0, 0, 115, 117, 7, 6, 0, 0, 116, 118, 7, 7, 0, 0, 117, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 7, 0, 0, 0, 122, 123, 7, 1, 0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0, 125, 28, 1, 0, 0, 0, 126, 127, 7, 1, 0, 0, 127, 128, 7, 0, 0, 0, 128, 129, 7, 1, 0, 0, 129, 130, 7, 2, 0, 0, 130, 131, 7, 3, 0, 0, 131, 30, 1, 0, 0, 0, 132, 133, 7, 4, 0, 0, 133, 134, 7, 5, 0, 0, 134, 136, 7, 6, 0, 0, 135, 137, 7, 7, 0, 0, 136, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 141, 7, 1, 0, 0, 141, 142, 7, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 7, 2, 0, 0, 144, 145, 7, 3, 0, 0, 145, 32, 1, 0, 0, 0, 146, 147, 7, 8, 0, 0, 147, 148, 7, 3, 0, 0, 148, 149, 7, 6, 0, 0, 149, 150, 7, 9, 0, 0, 150, 151, 7, 3, 0, 0, 151, 152, 7, 3, 0, 0, 152, 153, 7, 4, 0, 0, 153, 34, 1, 0, 0, 0, 154, 155, 7, 3, 0, 0, 155, 156, 7, 10, 0, 0, 156, 157, 7, 1, 0, 0, 157, 158, 7, 11, 0, 0, 158, 160, 7, 6, 0, 0, 159, 161, 7, 11, 0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 36, 1, 0, 0, 0, 162, 163, 7, 12, 0, 0, 163, 164, 7, 3, 0, 0, 164, 165, 7, 13, 0, 0, 165, 166, 7, 3, 0, 0, 166, 167, 7, 10, 0, 0, 167, 168, 7, 14, 0, 0, 168, 38, 1, 0, 0, 0, 169, 170, 7, 15, 0, 0, 170, 171, 7, 5, 0, 0, 171, 172, 7, 4, 0, 0, 172, 173, 7, 6, 0, 0, 173, 174, 7, 16, 0, 0, 174, 175, 7, 1, 0, 0, 175, 177, 7, 4, 0, 0, 176, 178, 7, 11, 0, 0, 177, 176, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 40, 1, 0, 0, 0, 179, 180, 7, 1, 0, 0, 180, 181, 7, 4, 0, 0, 181, 42, 1, 0, 0, 0, 182, 183, 7, 4, 0, 0, 183, 184, 7, 5, 0, 0, 184, 185, 7, 6, 0, 0, 185, 44, 1, 0, 0, 0, 186, 187, 7, 16, 0, 0, 187, 188, 7, 4, 0, 0, 188, 189, 7, 17, 0, 0, 189, 46, 1, 0, 0, 0, 190, 191, 7, 5, 0, 0, 191, 192, 7, 12, 0, 0, 192, 48, 1, 0, 0, 0, 193, 194, 7, 18, 0, 0, 194, 195, 7, 16, 0, 0, 195, 196, 7, 11, 0, 0, 196, 50, 1, 0, 0, 0, 197, 198, 7, 18, 0, 0, 198, 199, 7, 16, 0, 0, 199, 200, 7, 11, 0, 0, 200, 201, 7, 16, 0, 0, 201, 202, 7, 4, 0, 0, 202, 203, 7, 19, 0, 0, 203, 52, 1, 0, 0, 0, 204, 205, 7, 18, 0, 0, 205, 206, 7, 16, 0, 0, 206, 207, 7, 11, 0, 0, 207, 208, 7, 16, 0, 0, 208, 209, 7, 0, 0, 0, 209, 210, 7, 0, 0, 0, 210, 54, 1, 0, 0, 0, 211, 212, 7, 6, 0, 0, 212, 213, 7, 12, 0, 0, 213, 214, 7, 20, 0, 0, 214, 221, 7, 3, 0, 0, 215, 216, 7, 21, 0, 0, 216, 217, 7, 16, 0, 0, 217, 218, 7, 0, 0, 0, 218, 219, 7, 11, 0, 0, 219, 221, 7, 3, 0, 0, 220, 211, 1, 0, 0, 0, 220, 215, 1, 0, 0, 0, 221, 56, 1, 0, 0, 0, 222, 223, 7, 22, 0, 0, 223, 58, 1, 0, 0, 0, 224, 226, 3, 57, 28, 0, 225, 224, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 228, 1, 0, 0, 0, 227, 229, 3, 73, 36, 0, 228, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 239, 1, 0, 0, 0, 232, 236, 5, 46, 0, 0, 233, 235, 3, 73, 36, 0, 234, 233, 1, 0, 0, 0, 235, 238, 1, 0, 0, 0, 236, 234, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 240, 1, 0, 0, 0, 238, 236, 1, 0, 0, 0, 239, 232, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 250, 1, 0, 0, 0, 241, 243, 7, 3, 0, 0, 242, 244, 3, 57, 28, 0, 243, 242, 1, 0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 246, 1, 0, 0, 0, 245, 247, 3, 73, 36, 0, 246, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 251, 1, 0, 0, 0, 250, 241, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 273, 1, 0, 0, 0, 252, 254, 3, 57, 28, 0, 253, 252, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 257, 5, 46, 0, 0, 256, 258, 3, 73, 36, 0, 257, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 270, 1, 0, 0, 0, 261, 263, 7, 3, 0, 0, 262, 264, 3, 57, 28, 0, 263, 262, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 266, 1, 0, 0, 0, 265, 267, 3, 73, 36, 0, 266, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 271, 1, 0, 0, 0, 270, 261, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0, 271, 273, 1, 0, 0, 0, 272, 225, 1, 0, 0, 0, 272, 253, 1, 0, 0, 0, 273, 60, 1, 0, 0, 0, 274, 280, 5, 34, 0, 0, 275, 279, 8, 23, 0, 0, 276, 277, 5, 92, 0, 0, 277, 279, 9, 0, 0, 0, 278, 275, 1, 0, 0, 0, 278, 276, 1, 0, 0, 0, 279, 282, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 283, 1, 0, 0, 0, 282, 280, 1, 0, 0, 0, 283, 295, 5, 34, 0, 0, 284, 290, 5, 39, 0, 0, 285, 289, 8, 24, 0, 0, 286, 287, 5, 92, 0, 0, 287, 289, 9, 0, 0, 0, 288, 285, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 293, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 293, 295, 5, 39, 0, 0, 294, 274, 1, 0, 0, 0, 294, 284, 1, 0, 0, 0, 295, 62, 1, 0, 0, 0, 296, 300, 7, 25, 0, 0, 297, 299, 7, 26, 0, 0, 298, 297, 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, 0, 0, 301, 64, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 304, 5, 91, 0, 0, 304, 305, 5, 93, 0, 0, 305, 66, 1, 0, 0, 0, 306, 307, 5, 91, 0, 0, 307, 308, 5, 42, 0, 0, 308, 309, 5, 93, 0, 0, 309, 68, 1, 0, 0, 0, 310, 317, 3, 63, 31, 0, 311, 312, 5, 46, 0, 0, 312, 316, 3, 63, 31, 0, 313, 316, 3, 65, 32, 0, 314, 316, 3, 67, 33, 0, 315, 311, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 315, 314, 1, 0, 0, 0, 316, 319, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 70, 1, 0, 0, 0, 319, 317, 1, 0, 0, 0, 320, 322, 7, 27, 0, 0, 321, 320, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0, 323, 321, 1, 0, 0, 0, 323, 324, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 326, 6, 35, 0, 0, 326, 72, 1, 0, 0, 0, 327, 328, 7, 28, 0, 0, 328, 74, 1, 0, 0, 0, 329, 331, 8, 29, 0, 0, 330, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 332, 333, 1, 0, 0, 0, 333, 76, 1, 0, 0, 0, 30, 0, 90, 119, 138, 160, 177, 220, 225, 230, 236, 239, 243, 248, 250, 253, 259, 263, 268, 270, 272, 278, 280, 288, 290, 294, 300, 315, 317, 323, 332, 1, 6, 0, 0]
\ No newline at end of file
+[4, 0, 33, 334, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 3, 5, 91, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 4, 13, 118, 8, 13, 11, 13, 12, 13, 119, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 137, 8, 15, 11, 15, 12, 15, 138, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 161, 8, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 178, 8, 19, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 3, 27, 221, 8, 27, 1, 28, 1, 28, 1, 29, 3, 29, 226, 8, 29, 1, 29, 4, 29, 229, 8, 29, 11, 29, 12, 29, 230, 1, 29, 1, 29, 5, 29, 235, 8, 29, 10, 29, 12, 29, 238, 9, 29, 3, 29, 240, 8, 29, 1, 29, 1, 29, 3, 29, 244, 8, 29, 1, 29, 4, 29, 247, 8, 29, 11, 29, 12, 29, 248, 3, 29, 251, 8, 29, 1, 29, 3, 29, 254, 8, 29, 1, 29, 1, 29, 4, 29, 258, 8, 29, 11, 29, 12, 29, 259, 1, 29, 1, 29, 3, 29, 264, 8, 29, 1, 29, 4, 29, 267, 8, 29, 11, 29, 12, 29, 268, 3, 29, 271, 8, 29, 3, 29, 273, 8, 29, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 279, 8, 30, 10, 30, 12, 30, 282, 9, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 5, 30, 289, 8, 30, 10, 30, 12, 30, 292, 9, 30, 1, 30, 3, 30, 295, 8, 30, 1, 31, 1, 31, 5, 31, 299, 8, 31, 10, 31, 12, 31, 302, 9, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 316, 8, 34, 10, 34, 12, 34, 319, 9, 34, 1, 35, 4, 35, 322, 8, 35, 11, 35, 12, 35, 323, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 4, 37, 331, 8, 37, 11, 37, 12, 37, 332, 0, 0, 38, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 0, 59, 29, 61, 30, 63, 0, 65, 0, 67, 0, 69, 31, 71, 32, 73, 0, 75, 33, 1, 0, 30, 2, 0, 76, 76, 108, 108, 2, 0, 73, 73, 105, 105, 2, 0, 75, 75, 107, 107, 2, 0, 69, 69, 101, 101, 2, 0, 78, 78, 110, 110, 2, 0, 79, 79, 111, 111, 2, 0, 84, 84, 116, 116, 2, 0, 9, 9, 32, 32, 2, 0, 66, 66, 98, 98, 2, 0, 87, 87, 119, 119, 2, 0, 88, 88, 120, 120, 2, 0, 83, 83, 115, 115, 2, 0, 82, 82, 114, 114, 2, 0, 71, 71, 103, 103, 2, 0, 80, 80, 112, 112, 2, 0, 67, 67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100, 2, 0, 72, 72, 104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117, 2, 0, 70, 70, 102, 102, 2, 0, 43, 43, 45, 45, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39, 92, 92, 3, 0, 36, 36, 65, 90, 97, 122, 6, 0, 36, 36, 45, 45, 48, 58, 65, 90, 95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 8, 0, 9, 10, 13, 13, 32, 34, 39, 41, 44, 44, 60, 62, 91, 91, 93, 93, 358, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 79, 1, 0, 0, 0, 5, 81, 1, 0, 0, 0, 7, 83, 1, 0, 0, 0, 9, 85, 1, 0, 0, 0, 11, 90, 1, 0, 0, 0, 13, 92, 1, 0, 0, 0, 15, 95, 1, 0, 0, 0, 17, 98, 1, 0, 0, 0, 19, 100, 1, 0, 0, 0, 21, 103, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 108, 1, 0, 0, 0, 27, 113, 1, 0, 0, 0, 29, 126, 1, 0, 0, 0, 31, 132, 1, 0, 0, 0, 33, 146, 1, 0, 0, 0, 35, 154, 1, 0, 0, 0, 37, 162, 1, 0, 0, 0, 39, 169, 1, 0, 0, 0, 41, 179, 1, 0, 0, 0, 43, 182, 1, 0, 0, 0, 45, 186, 1, 0, 0, 0, 47, 190, 1, 0, 0, 0, 49, 193, 1, 0, 0, 0, 51, 197, 1, 0, 0, 0, 53, 204, 1, 0, 0, 0, 55, 220, 1, 0, 0, 0, 57, 222, 1, 0, 0, 0, 59, 272, 1, 0, 0, 0, 61, 294, 1, 0, 0, 0, 63, 296, 1, 0, 0, 0, 65, 303, 1, 0, 0, 0, 67, 306, 1, 0, 0, 0, 69, 310, 1, 0, 0, 0, 71, 321, 1, 0, 0, 0, 73, 327, 1, 0, 0, 0, 75, 330, 1, 0, 0, 0, 77, 78, 5, 40, 0, 0, 78, 2, 1, 0, 0, 0, 79, 80, 5, 41, 0, 0, 80, 4, 1, 0, 0, 0, 81, 82, 5, 91, 0, 0, 82, 6, 1, 0, 0, 0, 83, 84, 5, 93, 0, 0, 84, 8, 1, 0, 0, 0, 85, 86, 5, 44, 0, 0, 86, 10, 1, 0, 0, 0, 87, 91, 5, 61, 0, 0, 88, 89, 5, 61, 0, 0, 89, 91, 5, 61, 0, 0, 90, 87, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 12, 1, 0, 0, 0, 92, 93, 5, 33, 0, 0, 93, 94, 5, 61, 0, 0, 94, 14, 1, 0, 0, 0, 95, 96, 5, 60, 0, 0, 96, 97, 5, 62, 0, 0, 97, 16, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 18, 1, 0, 0, 0, 100, 101, 5, 60, 0, 0, 101, 102, 5, 61, 0, 0, 102, 20, 1, 0, 0, 0, 103, 104, 5, 62, 0, 0, 104, 22, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 107, 5, 61, 0, 0, 107, 24, 1, 0, 0, 0, 108, 109, 7, 0, 0, 0, 109, 110, 7, 1, 0, 0, 110, 111, 7, 2, 0, 0, 111, 112, 7, 3, 0, 0, 112, 26, 1, 0, 0, 0, 113, 114, 7, 4, 0, 0, 114, 115, 7, 5, 0, 0, 115, 117, 7, 6, 0, 0, 116, 118, 7, 7, 0, 0, 117, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 7, 0, 0, 0, 122, 123, 7, 1, 0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0, 125, 28, 1, 0, 0, 0, 126, 127, 7, 1, 0, 0, 127, 128, 7, 0, 0, 0, 128, 129, 7, 1, 0, 0, 129, 130, 7, 2, 0, 0, 130, 131, 7, 3, 0, 0, 131, 30, 1, 0, 0, 0, 132, 133, 7, 4, 0, 0, 133, 134, 7, 5, 0, 0, 134, 136, 7, 6, 0, 0, 135, 137, 7, 7, 0, 0, 136, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 141, 7, 1, 0, 0, 141, 142, 7, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 7, 2, 0, 0, 144, 145, 7, 3, 0, 0, 145, 32, 1, 0, 0, 0, 146, 147, 7, 8, 0, 0, 147, 148, 7, 3, 0, 0, 148, 149, 7, 6, 0, 0, 149, 150, 7, 9, 0, 0, 150, 151, 7, 3, 0, 0, 151, 152, 7, 3, 0, 0, 152, 153, 7, 4, 0, 0, 153, 34, 1, 0, 0, 0, 154, 155, 7, 3, 0, 0, 155, 156, 7, 10, 0, 0, 156, 157, 7, 1, 0, 0, 157, 158, 7, 11, 0, 0, 158, 160, 7, 6, 0, 0, 159, 161, 7, 11, 0, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 36, 1, 0, 0, 0, 162, 163, 7, 12, 0, 0, 163, 164, 7, 3, 0, 0, 164, 165, 7, 13, 0, 0, 165, 166, 7, 3, 0, 0, 166, 167, 7, 10, 0, 0, 167, 168, 7, 14, 0, 0, 168, 38, 1, 0, 0, 0, 169, 170, 7, 15, 0, 0, 170, 171, 7, 5, 0, 0, 171, 172, 7, 4, 0, 0, 172, 173, 7, 6, 0, 0, 173, 174, 7, 16, 0, 0, 174, 175, 7, 1, 0, 0, 175, 177, 7, 4, 0, 0, 176, 178, 7, 11, 0, 0, 177, 176, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 40, 1, 0, 0, 0, 179, 180, 7, 1, 0, 0, 180, 181, 7, 4, 0, 0, 181, 42, 1, 0, 0, 0, 182, 183, 7, 4, 0, 0, 183, 184, 7, 5, 0, 0, 184, 185, 7, 6, 0, 0, 185, 44, 1, 0, 0, 0, 186, 187, 7, 16, 0, 0, 187, 188, 7, 4, 0, 0, 188, 189, 7, 17, 0, 0, 189, 46, 1, 0, 0, 0, 190, 191, 7, 5, 0, 0, 191, 192, 7, 12, 0, 0, 192, 48, 1, 0, 0, 0, 193, 194, 7, 18, 0, 0, 194, 195, 7, 16, 0, 0, 195, 196, 7, 11, 0, 0, 196, 50, 1, 0, 0, 0, 197, 198, 7, 18, 0, 0, 198, 199, 7, 16, 0, 0, 199, 200, 7, 11, 0, 0, 200, 201, 7, 16, 0, 0, 201, 202, 7, 4, 0, 0, 202, 203, 7, 19, 0, 0, 203, 52, 1, 0, 0, 0, 204, 205, 7, 18, 0, 0, 205, 206, 7, 16, 0, 0, 206, 207, 7, 11, 0, 0, 207, 208, 7, 16, 0, 0, 208, 209, 7, 0, 0, 0, 209, 210, 7, 0, 0, 0, 210, 54, 1, 0, 0, 0, 211, 212, 7, 6, 0, 0, 212, 213, 7, 12, 0, 0, 213, 214, 7, 20, 0, 0, 214, 221, 7, 3, 0, 0, 215, 216, 7, 21, 0, 0, 216, 217, 7, 16, 0, 0, 217, 218, 7, 0, 0, 0, 218, 219, 7, 11, 0, 0, 219, 221, 7, 3, 0, 0, 220, 211, 1, 0, 0, 0, 220, 215, 1, 0, 0, 0, 221, 56, 1, 0, 0, 0, 222, 223, 7, 22, 0, 0, 223, 58, 1, 0, 0, 0, 224, 226, 3, 57, 28, 0, 225, 224, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 228, 1, 0, 0, 0, 227, 229, 3, 73, 36, 0, 228, 227, 1, 0, 0, 0, 229, 230, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 231, 1, 0, 0, 0, 231, 239, 1, 0, 0, 0, 232, 236, 5, 46, 0, 0, 233, 235, 3, 73, 36, 0, 234, 233, 1, 0, 0, 0, 235, 238, 1, 0, 0, 0, 236, 234, 1, 0, 0, 0, 236, 237, 1, 0, 0, 0, 237, 240, 1, 0, 0, 0, 238, 236, 1, 0, 0, 0, 239, 232, 1, 0, 0, 0, 239, 240, 1, 0, 0, 0, 240, 250, 1, 0, 0, 0, 241, 243, 7, 3, 0, 0, 242, 244, 3, 57, 28, 0, 243, 242, 1, 0, 0, 0, 243, 244, 1, 0, 0, 0, 244, 246, 1, 0, 0, 0, 245, 247, 3, 73, 36, 0, 246, 245, 1, 0, 0, 0, 247, 248, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 248, 249, 1, 0, 0, 0, 249, 251, 1, 0, 0, 0, 250, 241, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 273, 1, 0, 0, 0, 252, 254, 3, 57, 28, 0, 253, 252, 1, 0, 0, 0, 253, 254, 1, 0, 0, 0, 254, 255, 1, 0, 0, 0, 255, 257, 5, 46, 0, 0, 256, 258, 3, 73, 36, 0, 257, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 257, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 270, 1, 0, 0, 0, 261, 263, 7, 3, 0, 0, 262, 264, 3, 57, 28, 0, 263, 262, 1, 0, 0, 0, 263, 264, 1, 0, 0, 0, 264, 266, 1, 0, 0, 0, 265, 267, 3, 73, 36, 0, 266, 265, 1, 0, 0, 0, 267, 268, 1, 0, 0, 0, 268, 266, 1, 0, 0, 0, 268, 269, 1, 0, 0, 0, 269, 271, 1, 0, 0, 0, 270, 261, 1, 0, 0, 0, 270, 271, 1, 0, 0, 0, 271, 273, 1, 0, 0, 0, 272, 225, 1, 0, 0, 0, 272, 253, 1, 0, 0, 0, 273, 60, 1, 0, 0, 0, 274, 280, 5, 34, 0, 0, 275, 279, 8, 23, 0, 0, 276, 277, 5, 92, 0, 0, 277, 279, 9, 0, 0, 0, 278, 275, 1, 0, 0, 0, 278, 276, 1, 0, 0, 0, 279, 282, 1, 0, 0, 0, 280, 278, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 283, 1, 0, 0, 0, 282, 280, 1, 0, 0, 0, 283, 295, 5, 34, 0, 0, 284, 290, 5, 39, 0, 0, 285, 289, 8, 24, 0, 0, 286, 287, 5, 92, 0, 0, 287, 289, 9, 0, 0, 0, 288, 285, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 289, 292, 1, 0, 0, 0, 290, 288, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 293, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 293, 295, 5, 39, 0, 0, 294, 274, 1, 0, 0, 0, 294, 284, 1, 0, 0, 0, 295, 62, 1, 0, 0, 0, 296, 300, 7, 25, 0, 0, 297, 299, 7, 26, 0, 0, 298, 297, 1, 0, 0, 0, 299, 302, 1, 0, 0, 0, 300, 298, 1, 0, 0, 0, 300, 301, 1, 0, 0, 0, 301, 64, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 303, 304, 5, 91, 0, 0, 304, 305, 5, 93, 0, 0, 305, 66, 1, 0, 0, 0, 306, 307, 5, 91, 0, 0, 307, 308, 5, 42, 0, 0, 308, 309, 5, 93, 0, 0, 309, 68, 1, 0, 0, 0, 310, 317, 3, 63, 31, 0, 311, 312, 5, 46, 0, 0, 312, 316, 3, 63, 31, 0, 313, 316, 3, 65, 32, 0, 314, 316, 3, 67, 33, 0, 315, 311, 1, 0, 0, 0, 315, 313, 1, 0, 0, 0, 315, 314, 1, 0, 0, 0, 316, 319, 1, 0, 0, 0, 317, 315, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 70, 1, 0, 0, 0, 319, 317, 1, 0, 0, 0, 320, 322, 7, 27, 0, 0, 321, 320, 1, 0, 0, 0, 322, 323, 1, 0, 0, 0, 323, 321, 1, 0, 0, 0, 323, 324, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 326, 6, 35, 0, 0, 326, 72, 1, 0, 0, 0, 327, 328, 7, 28, 0, 0, 328, 74, 1, 0, 0, 0, 329, 331, 8, 29, 0, 0, 330, 329, 1, 0, 0, 0, 331, 332, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 332, 333, 1, 0, 0, 0, 333, 76, 1, 0, 0, 0, 30, 0, 90, 119, 138, 160, 177, 220, 225, 230, 236, 239, 243, 248, 250, 253, 259, 263, 268, 270, 272, 278, 280, 288, 290, 294, 300, 315, 317, 323, 332, 1, 6, 0, 0]
\ No newline at end of file
diff --git a/pkg/parser/grammar/filterquery_lexer.go b/pkg/parser/grammar/filterquery_lexer.go
index 29037753762..c43f13c81c4 100644
--- a/pkg/parser/grammar/filterquery_lexer.go
+++ b/pkg/parser/grammar/filterquery_lexer.go
@@ -110,53 +110,53 @@ func filterquerylexerLexerInit() {
 		67, 99, 99, 2, 0, 65, 65, 97, 97, 2, 0, 68, 68, 100, 100, 2, 0, 72, 72,
 		104, 104, 2, 0, 89, 89, 121, 121, 2, 0, 85, 85, 117, 117, 2, 0, 70, 70,
 		102, 102, 2, 0, 43, 43, 45, 45, 2, 0, 34, 34, 92, 92, 2, 0, 39, 39, 92,
-		92, 2, 0, 65, 90, 97, 122, 5, 0, 45, 45, 48, 58, 65, 90, 95, 95, 97, 122,
-		3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 8, 0, 9, 10, 13, 13, 32, 34,
-		39, 41, 44, 44, 60, 62, 91, 91, 93, 93, 358, 0, 1, 1, 0, 0, 0, 0, 3, 1,
-		0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1,
-		0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19,
-		1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0,
-		27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0,
-		0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0,
-		0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0,
-		0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 59, 1,
-		0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 75,
-		1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 79, 1, 0, 0, 0, 5, 81, 1, 0, 0, 0, 7,
-		83, 1, 0, 0, 0, 9, 85, 1, 0, 0, 0, 11, 90, 1, 0, 0, 0, 13, 92, 1, 0, 0,
-		0, 15, 95, 1, 0, 0, 0, 17, 98, 1, 0, 0, 0, 19, 100, 1, 0, 0, 0, 21, 103,
-		1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 108, 1, 0, 0, 0, 27, 113, 1, 0, 0,
-		0, 29, 126, 1, 0, 0, 0, 31, 132, 1, 0, 0, 0, 33, 146, 1, 0, 0, 0, 35, 154,
-		1, 0, 0, 0, 37, 162, 1, 0, 0, 0, 39, 169, 1, 0, 0, 0, 41, 179, 1, 0, 0,
-		0, 43, 182, 1, 0, 0, 0, 45, 186, 1, 0, 0, 0, 47, 190, 1, 0, 0, 0, 49, 193,
-		1, 0, 0, 0, 51, 197, 1, 0, 0, 0, 53, 204, 1, 0, 0, 0, 55, 220, 1, 0, 0,
-		0, 57, 222, 1, 0, 0, 0, 59, 272, 1, 0, 0, 0, 61, 294, 1, 0, 0, 0, 63, 296,
-		1, 0, 0, 0, 65, 303, 1, 0, 0, 0, 67, 306, 1, 0, 0, 0, 69, 310, 1, 0, 0,
-		0, 71, 321, 1, 0, 0, 0, 73, 327, 1, 0, 0, 0, 75, 330, 1, 0, 0, 0, 77, 78,
-		5, 40, 0, 0, 78, 2, 1, 0, 0, 0, 79, 80, 5, 41, 0, 0, 80, 4, 1, 0, 0, 0,
-		81, 82, 5, 91, 0, 0, 82, 6, 1, 0, 0, 0, 83, 84, 5, 93, 0, 0, 84, 8, 1,
-		0, 0, 0, 85, 86, 5, 44, 0, 0, 86, 10, 1, 0, 0, 0, 87, 91, 5, 61, 0, 0,
-		88, 89, 5, 61, 0, 0, 89, 91, 5, 61, 0, 0, 90, 87, 1, 0, 0, 0, 90, 88, 1,
-		0, 0, 0, 91, 12, 1, 0, 0, 0, 92, 93, 5, 33, 0, 0, 93, 94, 5, 61, 0, 0,
-		94, 14, 1, 0, 0, 0, 95, 96, 5, 60, 0, 0, 96, 97, 5, 62, 0, 0, 97, 16, 1,
-		0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 18, 1, 0, 0, 0, 100, 101, 5, 60, 0, 0,
-		101, 102, 5, 61, 0, 0, 102, 20, 1, 0, 0, 0, 103, 104, 5, 62, 0, 0, 104,
-		22, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 107, 5, 61, 0, 0, 107, 24,
-		1, 0, 0, 0, 108, 109, 7, 0, 0, 0, 109, 110, 7, 1, 0, 0, 110, 111, 7, 2,
-		0, 0, 111, 112, 7, 3, 0, 0, 112, 26, 1, 0, 0, 0, 113, 114, 7, 4, 0, 0,
-		114, 115, 7, 5, 0, 0, 115, 117, 7, 6, 0, 0, 116, 118, 7, 7, 0, 0, 117,
-		116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119, 120,
-		1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 7, 0, 0, 0, 122, 123, 7, 1,
-		0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0, 125, 28, 1, 0, 0, 0,
-		126, 127, 7, 1, 0, 0, 127, 128, 7, 0, 0, 0, 128, 129, 7, 1, 0, 0, 129,
-		130, 7, 2, 0, 0, 130, 131, 7, 3, 0, 0, 131, 30, 1, 0, 0, 0, 132, 133, 7,
-		4, 0, 0, 133, 134, 7, 5, 0, 0, 134, 136, 7, 6, 0, 0, 135, 137, 7, 7, 0,
-		0, 136, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0, 138,
-		139, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 141, 7, 1, 0, 0, 141, 142,
-		7, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 7, 2, 0, 0, 144, 145, 7, 3,
-		0, 0, 145, 32, 1, 0, 0, 0, 146, 147, 7, 8, 0, 0, 147, 148, 7, 3, 0, 0,
-		148, 149, 7, 6, 0, 0, 149, 150, 7, 9, 0, 0, 150, 151, 7, 3, 0, 0, 151,
-		152, 7, 3, 0, 0, 152, 153, 7, 4, 0, 0, 153, 34, 1, 0, 0, 0, 154, 155, 7,
-		3, 0, 0, 155, 156, 7, 10, 0, 0, 156, 157, 7, 1, 0, 0, 157, 158, 7, 11,
+		92, 3, 0, 36, 36, 65, 90, 97, 122, 6, 0, 36, 36, 45, 45, 48, 58, 65, 90,
+		95, 95, 97, 122, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 48, 57, 8, 0, 9, 10,
+		13, 13, 32, 34, 39, 41, 44, 44, 60, 62, 91, 91, 93, 93, 358, 0, 1, 1, 0,
+		0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0,
+		0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1,
+		0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25,
+		1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0,
+		33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0,
+		0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0,
+		0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0,
+		0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1,
+		0, 0, 0, 0, 75, 1, 0, 0, 0, 1, 77, 1, 0, 0, 0, 3, 79, 1, 0, 0, 0, 5, 81,
+		1, 0, 0, 0, 7, 83, 1, 0, 0, 0, 9, 85, 1, 0, 0, 0, 11, 90, 1, 0, 0, 0, 13,
+		92, 1, 0, 0, 0, 15, 95, 1, 0, 0, 0, 17, 98, 1, 0, 0, 0, 19, 100, 1, 0,
+		0, 0, 21, 103, 1, 0, 0, 0, 23, 105, 1, 0, 0, 0, 25, 108, 1, 0, 0, 0, 27,
+		113, 1, 0, 0, 0, 29, 126, 1, 0, 0, 0, 31, 132, 1, 0, 0, 0, 33, 146, 1,
+		0, 0, 0, 35, 154, 1, 0, 0, 0, 37, 162, 1, 0, 0, 0, 39, 169, 1, 0, 0, 0,
+		41, 179, 1, 0, 0, 0, 43, 182, 1, 0, 0, 0, 45, 186, 1, 0, 0, 0, 47, 190,
+		1, 0, 0, 0, 49, 193, 1, 0, 0, 0, 51, 197, 1, 0, 0, 0, 53, 204, 1, 0, 0,
+		0, 55, 220, 1, 0, 0, 0, 57, 222, 1, 0, 0, 0, 59, 272, 1, 0, 0, 0, 61, 294,
+		1, 0, 0, 0, 63, 296, 1, 0, 0, 0, 65, 303, 1, 0, 0, 0, 67, 306, 1, 0, 0,
+		0, 69, 310, 1, 0, 0, 0, 71, 321, 1, 0, 0, 0, 73, 327, 1, 0, 0, 0, 75, 330,
+		1, 0, 0, 0, 77, 78, 5, 40, 0, 0, 78, 2, 1, 0, 0, 0, 79, 80, 5, 41, 0, 0,
+		80, 4, 1, 0, 0, 0, 81, 82, 5, 91, 0, 0, 82, 6, 1, 0, 0, 0, 83, 84, 5, 93,
+		0, 0, 84, 8, 1, 0, 0, 0, 85, 86, 5, 44, 0, 0, 86, 10, 1, 0, 0, 0, 87, 91,
+		5, 61, 0, 0, 88, 89, 5, 61, 0, 0, 89, 91, 5, 61, 0, 0, 90, 87, 1, 0, 0,
+		0, 90, 88, 1, 0, 0, 0, 91, 12, 1, 0, 0, 0, 92, 93, 5, 33, 0, 0, 93, 94,
+		5, 61, 0, 0, 94, 14, 1, 0, 0, 0, 95, 96, 5, 60, 0, 0, 96, 97, 5, 62, 0,
+		0, 97, 16, 1, 0, 0, 0, 98, 99, 5, 60, 0, 0, 99, 18, 1, 0, 0, 0, 100, 101,
+		5, 60, 0, 0, 101, 102, 5, 61, 0, 0, 102, 20, 1, 0, 0, 0, 103, 104, 5, 62,
+		0, 0, 104, 22, 1, 0, 0, 0, 105, 106, 5, 62, 0, 0, 106, 107, 5, 61, 0, 0,
+		107, 24, 1, 0, 0, 0, 108, 109, 7, 0, 0, 0, 109, 110, 7, 1, 0, 0, 110, 111,
+		7, 2, 0, 0, 111, 112, 7, 3, 0, 0, 112, 26, 1, 0, 0, 0, 113, 114, 7, 4,
+		0, 0, 114, 115, 7, 5, 0, 0, 115, 117, 7, 6, 0, 0, 116, 118, 7, 7, 0, 0,
+		117, 116, 1, 0, 0, 0, 118, 119, 1, 0, 0, 0, 119, 117, 1, 0, 0, 0, 119,
+		120, 1, 0, 0, 0, 120, 121, 1, 0, 0, 0, 121, 122, 7, 0, 0, 0, 122, 123,
+		7, 1, 0, 0, 123, 124, 7, 2, 0, 0, 124, 125, 7, 3, 0, 0, 125, 28, 1, 0,
+		0, 0, 126, 127, 7, 1, 0, 0, 127, 128, 7, 0, 0, 0, 128, 129, 7, 1, 0, 0,
+		129, 130, 7, 2, 0, 0, 130, 131, 7, 3, 0, 0, 131, 30, 1, 0, 0, 0, 132, 133,
+		7, 4, 0, 0, 133, 134, 7, 5, 0, 0, 134, 136, 7, 6, 0, 0, 135, 137, 7, 7,
+		0, 0, 136, 135, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 136, 1, 0, 0, 0,
+		138, 139, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 141, 7, 1, 0, 0, 141,
+		142, 7, 0, 0, 0, 142, 143, 7, 1, 0, 0, 143, 144, 7, 2, 0, 0, 144, 145,
+		7, 3, 0, 0, 145, 32, 1, 0, 0, 0, 146, 147, 7, 8, 0, 0, 147, 148, 7, 3,
+		0, 0, 148, 149, 7, 6, 0, 0, 149, 150, 7, 9, 0, 0, 150, 151, 7, 3, 0, 0,
+		151, 152, 7, 3, 0, 0, 152, 153, 7, 4, 0, 0, 153, 34, 1, 0, 0, 0, 154, 155,
+		7, 3, 0, 0, 155, 156, 7, 10, 0, 0, 156, 157, 7, 1, 0, 0, 157, 158, 7, 11,
 		0, 0, 158, 160, 7, 6, 0, 0, 159, 161, 7, 11, 0, 0, 160, 159, 1, 0, 0, 0,
 		160, 161, 1, 0, 0, 0, 161, 36, 1, 0, 0, 0, 162, 163, 7, 12, 0, 0, 163,
 		164, 7, 3, 0, 0, 164, 165, 7, 13, 0, 0, 165, 166, 7, 3, 0, 0, 166, 167,
diff --git a/pkg/parser/grammar/filterquery_parser.go b/pkg/parser/grammar/filterquery_parser.go
index dfdc0075686..49b097f1697 100644
--- a/pkg/parser/grammar/filterquery_parser.go
+++ b/pkg/parser/grammar/filterquery_parser.go
@@ -51,7 +51,7 @@ func filterqueryParserInit() {
 	}
 	staticData.PredictionContextCache = antlr.NewPredictionContextCache()
 	staticData.serializedATN = []int32{
-		4, 1, 33, 213, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7,
+		4, 1, 33, 218, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7,
 		4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7,
 		10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15,
 		2, 16, 7, 16, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 5, 2, 43,
@@ -65,83 +65,86 @@ func filterqueryParserInit() {
 		6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1,
 		6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1,
 		6, 3, 6, 149, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1,
-		7, 1, 7, 3, 7, 161, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1,
-		8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 175, 8, 8, 1, 9, 1, 9, 1, 9, 5, 9, 180,
-		8, 9, 10, 9, 12, 9, 183, 9, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11,
-		1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 195, 8, 12, 10, 12, 12, 12, 198, 9,
-		12, 1, 13, 1, 13, 1, 13, 3, 13, 203, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14,
-		1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0, 17, 0, 2, 4, 6, 8, 10, 12, 14,
-		16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6, 1, 0, 7, 8, 2, 0, 13, 13, 15,
-		15, 2, 0, 14, 14, 16, 16, 2, 0, 30, 30, 33, 33, 1, 0, 25, 27, 1, 0, 28,
-		31, 227, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0, 0, 4, 39, 1, 0, 0, 0, 6, 47,
-		1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1, 0, 0, 0, 12, 148, 1, 0, 0, 0,
-		14, 160, 1, 0, 0, 0, 16, 174, 1, 0, 0, 0, 18, 176, 1, 0, 0, 0, 20, 184,
-		1, 0, 0, 0, 22, 186, 1, 0, 0, 0, 24, 191, 1, 0, 0, 0, 26, 202, 1, 0, 0,
-		0, 28, 204, 1, 0, 0, 0, 30, 208, 1, 0, 0, 0, 32, 210, 1, 0, 0, 0, 34, 35,
-		3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1, 1, 0, 0, 0, 37, 38, 3, 4, 2, 0,
-		38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0, 40, 41, 5, 24, 0, 0, 41, 43, 3,
-		6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44,
-		45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 47, 53, 3, 8, 4,
-		0, 48, 49, 5, 23, 0, 0, 49, 52, 3, 8, 4, 0, 50, 52, 3, 8, 4, 0, 51, 48,
-		1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0,
-		53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0, 55, 53, 1, 0, 0, 0, 56, 58, 5, 22,
-		0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60,
-		3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61, 62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0,
-		63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0, 0, 65, 71, 3, 12, 6, 0, 66, 71, 3,
-		22, 11, 0, 67, 71, 3, 20, 10, 0, 68, 71, 3, 32, 16, 0, 69, 71, 3, 30, 15,
-		0, 70, 61, 1, 0, 0, 0, 70, 65, 1, 0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67,
-		1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0,
-		72, 73, 3, 32, 16, 0, 73, 74, 5, 6, 0, 0, 74, 75, 3, 30, 15, 0, 75, 149,
-		1, 0, 0, 0, 76, 77, 3, 32, 16, 0, 77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15,
-		0, 79, 149, 1, 0, 0, 0, 80, 81, 3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83,
-		3, 30, 15, 0, 83, 149, 1, 0, 0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10,
-		0, 0, 86, 87, 3, 30, 15, 0, 87, 149, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0,
-		89, 90, 5, 11, 0, 0, 90, 91, 3, 30, 15, 0, 91, 149, 1, 0, 0, 0, 92, 93,
-		3, 32, 16, 0, 93, 94, 5, 12, 0, 0, 94, 95, 3, 30, 15, 0, 95, 149, 1, 0,
-		0, 0, 96, 97, 3, 32, 16, 0, 97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99,
-		149, 1, 0, 0, 0, 100, 101, 3, 32, 16, 0, 101, 102, 7, 2, 0, 0, 102, 103,
-		3, 30, 15, 0, 103, 149, 1, 0, 0, 0, 104, 105, 3, 32, 16, 0, 105, 106, 5,
-		17, 0, 0, 106, 107, 3, 30, 15, 0, 107, 108, 5, 23, 0, 0, 108, 109, 3, 30,
-		15, 0, 109, 149, 1, 0, 0, 0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 22, 0,
-		0, 112, 113, 5, 17, 0, 0, 113, 114, 3, 30, 15, 0, 114, 115, 5, 23, 0, 0,
-		115, 116, 3, 30, 15, 0, 116, 149, 1, 0, 0, 0, 117, 118, 3, 32, 16, 0, 118,
-		119, 3, 14, 7, 0, 119, 149, 1, 0, 0, 0, 120, 121, 3, 32, 16, 0, 121, 122,
-		3, 16, 8, 0, 122, 149, 1, 0, 0, 0, 123, 124, 3, 32, 16, 0, 124, 125, 5,
-		18, 0, 0, 125, 149, 1, 0, 0, 0, 126, 127, 3, 32, 16, 0, 127, 128, 5, 22,
-		0, 0, 128, 129, 5, 18, 0, 0, 129, 149, 1, 0, 0, 0, 130, 131, 3, 32, 16,
-		0, 131, 132, 5, 19, 0, 0, 132, 133, 3, 30, 15, 0, 133, 149, 1, 0, 0, 0,
-		134, 135, 3, 32, 16, 0, 135, 136, 5, 22, 0, 0, 136, 137, 5, 19, 0, 0, 137,
-		138, 3, 30, 15, 0, 138, 149, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 141,
-		5, 20, 0, 0, 141, 142, 3, 30, 15, 0, 142, 149, 1, 0, 0, 0, 143, 144, 3,
-		32, 16, 0, 144, 145, 5, 22, 0, 0, 145, 146, 5, 20, 0, 0, 146, 147, 3, 30,
-		15, 0, 147, 149, 1, 0, 0, 0, 148, 72, 1, 0, 0, 0, 148, 76, 1, 0, 0, 0,
-		148, 80, 1, 0, 0, 0, 148, 84, 1, 0, 0, 0, 148, 88, 1, 0, 0, 0, 148, 92,
-		1, 0, 0, 0, 148, 96, 1, 0, 0, 0, 148, 100, 1, 0, 0, 0, 148, 104, 1, 0,
-		0, 0, 148, 110, 1, 0, 0, 0, 148, 117, 1, 0, 0, 0, 148, 120, 1, 0, 0, 0,
-		148, 123, 1, 0, 0, 0, 148, 126, 1, 0, 0, 0, 148, 130, 1, 0, 0, 0, 148,
-		134, 1, 0, 0, 0, 148, 139, 1, 0, 0, 0, 148, 143, 1, 0, 0, 0, 149, 13, 1,
-		0, 0, 0, 150, 151, 5, 21, 0, 0, 151, 152, 5, 1, 0, 0, 152, 153, 3, 18,
-		9, 0, 153, 154, 5, 2, 0, 0, 154, 161, 1, 0, 0, 0, 155, 156, 5, 21, 0, 0,
-		156, 157, 5, 3, 0, 0, 157, 158, 3, 18, 9, 0, 158, 159, 5, 4, 0, 0, 159,
-		161, 1, 0, 0, 0, 160, 150, 1, 0, 0, 0, 160, 155, 1, 0, 0, 0, 161, 15, 1,
-		0, 0, 0, 162, 163, 5, 22, 0, 0, 163, 164, 5, 21, 0, 0, 164, 165, 5, 1,
-		0, 0, 165, 166, 3, 18, 9, 0, 166, 167, 5, 2, 0, 0, 167, 175, 1, 0, 0, 0,
-		168, 169, 5, 22, 0, 0, 169, 170, 5, 21, 0, 0, 170, 171, 5, 3, 0, 0, 171,
-		172, 3, 18, 9, 0, 172, 173, 5, 4, 0, 0, 173, 175, 1, 0, 0, 0, 174, 162,
-		1, 0, 0, 0, 174, 168, 1, 0, 0, 0, 175, 17, 1, 0, 0, 0, 176, 181, 3, 30,
-		15, 0, 177, 178, 5, 5, 0, 0, 178, 180, 3, 30, 15, 0, 179, 177, 1, 0, 0,
-		0, 180, 183, 1, 0, 0, 0, 181, 179, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182,
-		19, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 184, 185, 7, 3, 0, 0, 185, 21, 1,
-		0, 0, 0, 186, 187, 7, 4, 0, 0, 187, 188, 5, 1, 0, 0, 188, 189, 3, 24, 12,
-		0, 189, 190, 5, 2, 0, 0, 190, 23, 1, 0, 0, 0, 191, 196, 3, 26, 13, 0, 192,
-		193, 5, 5, 0, 0, 193, 195, 3, 26, 13, 0, 194, 192, 1, 0, 0, 0, 195, 198,
-		1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 25, 1, 0,
-		0, 0, 198, 196, 1, 0, 0, 0, 199, 203, 3, 32, 16, 0, 200, 203, 3, 30, 15,
-		0, 201, 203, 3, 28, 14, 0, 202, 199, 1, 0, 0, 0, 202, 200, 1, 0, 0, 0,
-		202, 201, 1, 0, 0, 0, 203, 27, 1, 0, 0, 0, 204, 205, 5, 3, 0, 0, 205, 206,
-		3, 18, 9, 0, 206, 207, 5, 4, 0, 0, 207, 29, 1, 0, 0, 0, 208, 209, 7, 5,
-		0, 0, 209, 31, 1, 0, 0, 0, 210, 211, 5, 31, 0, 0, 211, 33, 1, 0, 0, 0,
-		11, 44, 51, 53, 57, 70, 148, 160, 174, 181, 196, 202,
+		7, 1, 7, 1, 7, 1, 7, 3, 7, 163, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1,
+		8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 180, 8,
+		8, 1, 9, 1, 9, 1, 9, 5, 9, 185, 8, 9, 10, 9, 12, 9, 188, 9, 9, 1, 10, 1,
+		10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 200,
+		8, 12, 10, 12, 12, 12, 203, 9, 12, 1, 13, 1, 13, 1, 13, 3, 13, 208, 8,
+		13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 0,
+		17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 6,
+		1, 0, 7, 8, 2, 0, 13, 13, 15, 15, 2, 0, 14, 14, 16, 16, 2, 0, 30, 30, 33,
+		33, 1, 0, 25, 27, 1, 0, 28, 31, 234, 0, 34, 1, 0, 0, 0, 2, 37, 1, 0, 0,
+		0, 4, 39, 1, 0, 0, 0, 6, 47, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 70, 1,
+		0, 0, 0, 12, 148, 1, 0, 0, 0, 14, 162, 1, 0, 0, 0, 16, 179, 1, 0, 0, 0,
+		18, 181, 1, 0, 0, 0, 20, 189, 1, 0, 0, 0, 22, 191, 1, 0, 0, 0, 24, 196,
+		1, 0, 0, 0, 26, 207, 1, 0, 0, 0, 28, 209, 1, 0, 0, 0, 30, 213, 1, 0, 0,
+		0, 32, 215, 1, 0, 0, 0, 34, 35, 3, 2, 1, 0, 35, 36, 5, 0, 0, 1, 36, 1,
+		1, 0, 0, 0, 37, 38, 3, 4, 2, 0, 38, 3, 1, 0, 0, 0, 39, 44, 3, 6, 3, 0,
+		40, 41, 5, 24, 0, 0, 41, 43, 3, 6, 3, 0, 42, 40, 1, 0, 0, 0, 43, 46, 1,
+		0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 5, 1, 0, 0, 0, 46,
+		44, 1, 0, 0, 0, 47, 53, 3, 8, 4, 0, 48, 49, 5, 23, 0, 0, 49, 52, 3, 8,
+		4, 0, 50, 52, 3, 8, 4, 0, 51, 48, 1, 0, 0, 0, 51, 50, 1, 0, 0, 0, 52, 55,
+		1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 7, 1, 0, 0, 0,
+		55, 53, 1, 0, 0, 0, 56, 58, 5, 22, 0, 0, 57, 56, 1, 0, 0, 0, 57, 58, 1,
+		0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 3, 10, 5, 0, 60, 9, 1, 0, 0, 0, 61,
+		62, 5, 1, 0, 0, 62, 63, 3, 4, 2, 0, 63, 64, 5, 2, 0, 0, 64, 71, 1, 0, 0,
+		0, 65, 71, 3, 12, 6, 0, 66, 71, 3, 22, 11, 0, 67, 71, 3, 20, 10, 0, 68,
+		71, 3, 32, 16, 0, 69, 71, 3, 30, 15, 0, 70, 61, 1, 0, 0, 0, 70, 65, 1,
+		0, 0, 0, 70, 66, 1, 0, 0, 0, 70, 67, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70,
+		69, 1, 0, 0, 0, 71, 11, 1, 0, 0, 0, 72, 73, 3, 32, 16, 0, 73, 74, 5, 6,
+		0, 0, 74, 75, 3, 30, 15, 0, 75, 149, 1, 0, 0, 0, 76, 77, 3, 32, 16, 0,
+		77, 78, 7, 0, 0, 0, 78, 79, 3, 30, 15, 0, 79, 149, 1, 0, 0, 0, 80, 81,
+		3, 32, 16, 0, 81, 82, 5, 9, 0, 0, 82, 83, 3, 30, 15, 0, 83, 149, 1, 0,
+		0, 0, 84, 85, 3, 32, 16, 0, 85, 86, 5, 10, 0, 0, 86, 87, 3, 30, 15, 0,
+		87, 149, 1, 0, 0, 0, 88, 89, 3, 32, 16, 0, 89, 90, 5, 11, 0, 0, 90, 91,
+		3, 30, 15, 0, 91, 149, 1, 0, 0, 0, 92, 93, 3, 32, 16, 0, 93, 94, 5, 12,
+		0, 0, 94, 95, 3, 30, 15, 0, 95, 149, 1, 0, 0, 0, 96, 97, 3, 32, 16, 0,
+		97, 98, 7, 1, 0, 0, 98, 99, 3, 30, 15, 0, 99, 149, 1, 0, 0, 0, 100, 101,
+		3, 32, 16, 0, 101, 102, 7, 2, 0, 0, 102, 103, 3, 30, 15, 0, 103, 149, 1,
+		0, 0, 0, 104, 105, 3, 32, 16, 0, 105, 106, 5, 17, 0, 0, 106, 107, 3, 30,
+		15, 0, 107, 108, 5, 23, 0, 0, 108, 109, 3, 30, 15, 0, 109, 149, 1, 0, 0,
+		0, 110, 111, 3, 32, 16, 0, 111, 112, 5, 22, 0, 0, 112, 113, 5, 17, 0, 0,
+		113, 114, 3, 30, 15, 0, 114, 115, 5, 23, 0, 0, 115, 116, 3, 30, 15, 0,
+		116, 149, 1, 0, 0, 0, 117, 118, 3, 32, 16, 0, 118, 119, 3, 14, 7, 0, 119,
+		149, 1, 0, 0, 0, 120, 121, 3, 32, 16, 0, 121, 122, 3, 16, 8, 0, 122, 149,
+		1, 0, 0, 0, 123, 124, 3, 32, 16, 0, 124, 125, 5, 18, 0, 0, 125, 149, 1,
+		0, 0, 0, 126, 127, 3, 32, 16, 0, 127, 128, 5, 22, 0, 0, 128, 129, 5, 18,
+		0, 0, 129, 149, 1, 0, 0, 0, 130, 131, 3, 32, 16, 0, 131, 132, 5, 19, 0,
+		0, 132, 133, 3, 30, 15, 0, 133, 149, 1, 0, 0, 0, 134, 135, 3, 32, 16, 0,
+		135, 136, 5, 22, 0, 0, 136, 137, 5, 19, 0, 0, 137, 138, 3, 30, 15, 0, 138,
+		149, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 141, 5, 20, 0, 0, 141, 142,
+		3, 30, 15, 0, 142, 149, 1, 0, 0, 0, 143, 144, 3, 32, 16, 0, 144, 145, 5,
+		22, 0, 0, 145, 146, 5, 20, 0, 0, 146, 147, 3, 30, 15, 0, 147, 149, 1, 0,
+		0, 0, 148, 72, 1, 0, 0, 0, 148, 76, 1, 0, 0, 0, 148, 80, 1, 0, 0, 0, 148,
+		84, 1, 0, 0, 0, 148, 88, 1, 0, 0, 0, 148, 92, 1, 0, 0, 0, 148, 96, 1, 0,
+		0, 0, 148, 100, 1, 0, 0, 0, 148, 104, 1, 0, 0, 0, 148, 110, 1, 0, 0, 0,
+		148, 117, 1, 0, 0, 0, 148, 120, 1, 0, 0, 0, 148, 123, 1, 0, 0, 0, 148,
+		126, 1, 0, 0, 0, 148, 130, 1, 0, 0, 0, 148, 134, 1, 0, 0, 0, 148, 139,
+		1, 0, 0, 0, 148, 143, 1, 0, 0, 0, 149, 13, 1, 0, 0, 0, 150, 151, 5, 21,
+		0, 0, 151, 152, 5, 1, 0, 0, 152, 153, 3, 18, 9, 0, 153, 154, 5, 2, 0, 0,
+		154, 163, 1, 0, 0, 0, 155, 156, 5, 21, 0, 0, 156, 157, 5, 3, 0, 0, 157,
+		158, 3, 18, 9, 0, 158, 159, 5, 4, 0, 0, 159, 163, 1, 0, 0, 0, 160, 161,
+		5, 21, 0, 0, 161, 163, 3, 30, 15, 0, 162, 150, 1, 0, 0, 0, 162, 155, 1,
+		0, 0, 0, 162, 160, 1, 0, 0, 0, 163, 15, 1, 0, 0, 0, 164, 165, 5, 22, 0,
+		0, 165, 166, 5, 21, 0, 0, 166, 167, 5, 1, 0, 0, 167, 168, 3, 18, 9, 0,
+		168, 169, 5, 2, 0, 0, 169, 180, 1, 0, 0, 0, 170, 171, 5, 22, 0, 0, 171,
+		172, 5, 21, 0, 0, 172, 173, 5, 3, 0, 0, 173, 174, 3, 18, 9, 0, 174, 175,
+		5, 4, 0, 0, 175, 180, 1, 0, 0, 0, 176, 177, 5, 22, 0, 0, 177, 178, 5, 21,
+		0, 0, 178, 180, 3, 30, 15, 0, 179, 164, 1, 0, 0, 0, 179, 170, 1, 0, 0,
+		0, 179, 176, 1, 0, 0, 0, 180, 17, 1, 0, 0, 0, 181, 186, 3, 30, 15, 0, 182,
+		183, 5, 5, 0, 0, 183, 185, 3, 30, 15, 0, 184, 182, 1, 0, 0, 0, 185, 188,
+		1, 0, 0, 0, 186, 184, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 19, 1, 0,
+		0, 0, 188, 186, 1, 0, 0, 0, 189, 190, 7, 3, 0, 0, 190, 21, 1, 0, 0, 0,
+		191, 192, 7, 4, 0, 0, 192, 193, 5, 1, 0, 0, 193, 194, 3, 24, 12, 0, 194,
+		195, 5, 2, 0, 0, 195, 23, 1, 0, 0, 0, 196, 201, 3, 26, 13, 0, 197, 198,
+		5, 5, 0, 0, 198, 200, 3, 26, 13, 0, 199, 197, 1, 0, 0, 0, 200, 203, 1,
+		0, 0, 0, 201, 199, 1, 0, 0, 0, 201, 202, 1, 0, 0, 0, 202, 25, 1, 0, 0,
+		0, 203, 201, 1, 0, 0, 0, 204, 208, 3, 32, 16, 0, 205, 208, 3, 30, 15, 0,
+		206, 208, 3, 28, 14, 0, 207, 204, 1, 0, 0, 0, 207, 205, 1, 0, 0, 0, 207,
+		206, 1, 0, 0, 0, 208, 27, 1, 0, 0, 0, 209, 210, 5, 3, 0, 0, 210, 211, 3,
+		18, 9, 0, 211, 212, 5, 4, 0, 0, 212, 29, 1, 0, 0, 0, 213, 214, 7, 5, 0,
+		0, 214, 31, 1, 0, 0, 0, 215, 216, 5, 31, 0, 0, 216, 33, 1, 0, 0, 0, 11,
+		44, 51, 53, 57, 70, 148, 162, 179, 186, 201, 207,
 	}
 	deserializer := antlr.NewATNDeserializer(nil)
 	staticData.atn = deserializer.Deserialize(staticData.serializedATN)
@@ -1947,6 +1950,7 @@ type IInClauseContext interface {
 	RPAREN() antlr.TerminalNode
 	LBRACK() antlr.TerminalNode
 	RBRACK() antlr.TerminalNode
+	Value() IValueContext
 
 	// IsInClauseContext differentiates from other interfaces.
 	IsInClauseContext()
@@ -2020,6 +2024,22 @@ func (s *InClauseContext) RBRACK() antlr.TerminalNode {
 	return s.GetToken(FilterQueryParserRBRACK, 0)
 }
 
+func (s *InClauseContext) Value() IValueContext {
+	var t antlr.RuleContext
+	for _, ctx := range s.GetChildren() {
+		if _, ok := ctx.(IValueContext); ok {
+			t = ctx.(antlr.RuleContext)
+			break
+		}
+	}
+
+	if t == nil {
+		return nil
+	}
+
+	return t.(IValueContext)
+}
+
 func (s *InClauseContext) GetRuleContext() antlr.RuleContext {
 	return s
 }
@@ -2053,7 +2073,7 @@ func (s *InClauseContext) Accept(visitor antlr.ParseTreeVisitor) interface{} {
 func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
 	localctx = NewInClauseContext(p, p.GetParserRuleContext(), p.GetState())
 	p.EnterRule(localctx, 14, FilterQueryParserRULE_inClause)
-	p.SetState(160)
+	p.SetState(162)
 	p.GetErrorHandler().Sync(p)
 	if p.HasError() {
 		goto errorExit
@@ -2122,6 +2142,21 @@ func (p *FilterQueryParser) InClause() (localctx IInClauseContext) {
 			}
 		}
 
+	case 3:
+		p.EnterOuterAlt(localctx, 3)
+		{
+			p.SetState(160)
+			p.Match(FilterQueryParserIN)
+			if p.HasError() {
+				// Recognition error - abort rule
+				goto errorExit
+			}
+		}
+		{
+			p.SetState(161)
+			p.Value()
+		}
+
 	case antlr.ATNInvalidAltNumber:
 		goto errorExit
 	}
@@ -2154,6 +2189,7 @@ type INotInClauseContext interface {
 	RPAREN() antlr.TerminalNode
 	LBRACK() antlr.TerminalNode
 	RBRACK() antlr.TerminalNode
+	Value() IValueContext
 
 	// IsNotInClauseContext differentiates from other interfaces.
 	IsNotInClauseContext()
@@ -2231,6 +2267,22 @@ func (s *NotInClauseContext) RBRACK() antlr.TerminalNode {
 	return s.GetToken(FilterQueryParserRBRACK, 0)
 }
 
+func (s *NotInClauseContext) Value() IValueContext {
+	var t antlr.RuleContext
+	for _, ctx := range s.GetChildren() {
+		if _, ok := ctx.(IValueContext); ok {
+			t = ctx.(antlr.RuleContext)
+			break
+		}
+	}
+
+	if t == nil {
+		return nil
+	}
+
+	return t.(IValueContext)
+}
+
 func (s *NotInClauseContext) GetRuleContext() antlr.RuleContext {
 	return s
 }
@@ -2264,7 +2316,7 @@ func (s *NotInClauseContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
 func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
 	localctx = NewNotInClauseContext(p, p.GetParserRuleContext(), p.GetState())
 	p.EnterRule(localctx, 16, FilterQueryParserRULE_notInClause)
-	p.SetState(174)
+	p.SetState(179)
 	p.GetErrorHandler().Sync(p)
 	if p.HasError() {
 		goto errorExit
@@ -2274,7 +2326,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
 	case 1:
 		p.EnterOuterAlt(localctx, 1)
 		{
-			p.SetState(162)
+			p.SetState(164)
 			p.Match(FilterQueryParserNOT)
 			if p.HasError() {
 				// Recognition error - abort rule
@@ -2282,7 +2334,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
 			}
 		}
 		{
-			p.SetState(163)
+			p.SetState(165)
 			p.Match(FilterQueryParserIN)
 			if p.HasError() {
 				// Recognition error - abort rule
@@ -2290,7 +2342,7 @@ func (p *FilterQueryParser) NotInClause() (localctx INotInClauseContext) {
 			}
 		}
 		{
-			p.SetState(164)
+			p.SetState(166)
 			p.Match(FilterQueryParserLPAREN)
 			if p.HasError() {
 				// Recognition error - abort rule

Leaderboard for this case

hard · 0 of 9 bots fully caught it (0% solve rate) · 53% avg coverage.

#BotResultCaughtCoverageFindingsFalse alarms
1 Claude Code (Opus 5.5) partial 8/9 85.7% 11 0
2 Drape (Deep Review) partial 6/9 71.4% 16 0
3 qodo partial 6/9 71.4% 11 1
4 Mjolnir (Opus 5.5) partial 5/9 64.3% 8 0
5 cursor partial 4/9 57.1% 4 0
6 Drape (Review) partial 4/9 57.1% 10 0
7 Mjolnir (Sonnet 5.5) partial 4/9 57.1% 7 0
8 Cubic partial 4/9 50.0% 20 1
9 greptile partial 2/9 28.6% 4 1

Bot results

Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ off by one
d5 medium ✓ exact
d6 medium ✓ exact
d7 medium ✓ exact
d8 medium ✓ off by one
d9 high ✓ exact
valid · matches d3 · impact high
valid · matches d9 · impact high
valid · matches d2 · impact high
valid · impact medium
The fallback slices off the first character without checking that it is '$'. So a literal like 'xenv' matches variable 'env' and gets replaced by that variable's value. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d4 · impact high
valid · impact high
The builder Fingerprint includes only the raw filter expression, not variable values. This change makes filters resolve variables, so a cached result is reused after a variable changes. [grounded: tree pkg/querier/builder_query.go] [consensus 3/3: valid=3]
valid · matches d6 · impact medium
valid · matches d8 · impact medium
valid · matches d7 · impact medium
valid · impact low
The log line leaves out the error, and the function returns an empty fingerprint. This is a minor observability gap. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
The logs condition builder returns "true" for EXISTS and NOT EXISTS on any intrinsic field. scope_name and scope_version used to get a real check against the empty string, so exists filters on them no longer filter anything. [grounded: diff] [consensus 3/3: valid=3]
raw comments (11)
pkg/querier/clickhouse_query.go:65
`renderVars` calls `formatValueForCH(v)` with the whole `qbtypes.VariableItem` struct instead of `v.Value`. The struct matches no case in the type switch, so it falls to `default` and returns "". Every user dashboard variable (`{{var}}`, `[[var]]`, `$var`) in a ClickHouse SQL query is replaced with an empty string, which produces invalid or wrong SQL. Only the reserved time variables get the right value.
pkg/querier/promql_query.go:66
Same bug as the ClickHouse path: `formatValueForProm(v)` gets the `VariableItem` struct rather than `v.Value`, so it always returns "". Every user variable in a PromQL query is replaced with an empty string.
pkg/querybuilder/where_clause_visitor.go:427
Any string comparison value that doesn't match a variable name is retried as `v.variables[var_[1:]]`. If the value is an empty string (e.g. `service.name = ''`), `var_[1:]` is out of range and panics. The same thing happens in the IN path for `x IN ''` (line ~347). A legitimate filter now crashes the request; the new recover only turns this into a 500.
pkg/querybuilder/where_clause_visitor.go:427
The fallback lookup strips the first character whether or not it is `$`. Any literal filter value whose tail matches a variable name gets silently replaced. For example, with a variable `env`, the filter `deployment = 'xenv'` or `deployment IN ('venv')` becomes the variable's value. Literal values without a `$` prefix should never be looked up this way, and the prefix should only be stripped when it is actually `$`.
pkg/querybuilder/where_clause_visitor.go:433
When a variable's value is an empty `[]any` (e.g. a multi-select with nothing selected), `value = varValues[0]` panics with index out of range. In the IN path, an empty list leaves `values` empty and builds an invalid IN condition.
pkg/querier/builder_query.go:89
Builder queries now resolve `$variables` inside filter expressions, but `Fingerprint()` only includes the raw filter expression and not the variable values. Cached metric and timeseries results for `service = $svc` get reused when the dashboard variable changes, so users see stale data for the wrong selection.
pkg/querier/clickhouse_query.go:85
Every ClickHouse SQL query now goes through `text/template.Parse/Execute`. Valid SQL that contains `{{` or `}}` (in string literals, JSON or regex) now fails with 'error while replacing template variables'. Plain `strings.Replace` of `$name` with no word boundary also corrupts identifiers that share a prefix with a variable name (e.g. variable `a` rewrites `$abc`).
pkg/querybuilder/having_rewriter.go:104
`rewriteExpression` swaps quoted strings for placeholders before matching, but the aggregation expressions in the column map keep their original quotes. A having clause that repeats an aggregation containing a quoted literal (e.g. `countIf(level='error') > 5`) is never rewritten, and ClickHouse gets the raw expression.
pkg/apis/fields/parse.go:73
The field-keys endpoint now reads the `searchText` query param instead of `name`, and field-values reads `searchText` instead of `value`. Existing clients that send `name=`/`value=` silently lose their filtering: key search returns all keys, and value search ignores the typed text. This is a breaking API change.
pkg/querier/promql_query.go:46
If template rendering fails, `Fingerprint()` logs the error and returns "". The error is swallowed here and only shows up later in `Execute`, and the log line leaves out the error itself.
pkg/telemetrylogs/const.go:13
Adding `scope_name` and `scope_version` to the logs `IntrinsicFields` makes `scope_name EXISTS` always return `true` and `NOT EXISTS` always return false. These are plain string columns that are often empty, so the exists filters on them no longer work.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✗ —
d3 high ✓ exact
d4 high ✓ exact
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✓ off by one
d9 high ✓ exact
valid · impact medium
timestamp no longer appears in any trace field list, so ConditionFor now ANDs on an exists check, and for the DateTime64 column that check is `timestamp <> ''`. The tests use Contains, so the claim that they break is overstated, but the spurious predicate is real. [grounded: tree pkg/telemetrytraces/condition_builder.go] [consensus 5/5: valid=5]
valid · matches d8 · impact medium
valid
Values are written by position, using columns from the first series. It is not shown whether the evaluator can actually return series with differing label sets. [grounded: diff-section pkg/querier/postprocess.go] [consensus 5/5: valid=5]
valid · matches d3 · impact high
valid · impact low
I could not confirm the malformed And/Or claim because it depends on the sqlbuilder version. The scalar path does lack `__all__` handling, so the literal `__all__` is compared. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 4/5: valid=4, uncertain=1]
valid · matches d4 · impact high
valid · impact low
The static keys are appended without deduping against the keys returned by the fields-table query. [grounded: tree pkg/telemetrymetadata/metadata.go] [consensus 5/5: valid=5]
valid · impact low
Fingerprint includes rendered time vars, so queries with reserved time variables get unique cache keys per window. [grounded: tree pkg/querier/promql_query.go] [consensus 3/5: valid=3, uncertain=2]
valid · impact low
applySeriesLimit returns early on ScalarData, so the formula limit is ignored for scalar requests. [grounded: tree pkg/querier/postprocess.go] [consensus 5/5: valid=5]
valid · impact low
The extra exists predicate is real but semantically harmless. The claim about key suggestions is wrong: static keys were not returned before this change. [grounded: tree pkg/telemetrylogs/condition_builder.go] [consensus 4/5: valid=4, uncertain=1]
minor
This concerns test coverage, not runtime behaviour. [consensus 5/5: minor=5]
valid · impact low
`key in word` now parses as an IN comparison where it was previously a syntax error. This is real but edge-case. [grounded: tree grammar/FilterQuery.g4] [consensus 4/5: valid=4, uncertain=1]
valid · impact low
The limit CTE now skips HAVING while the outer query keeps it, so top-N is chosen before HAVING filters and panels can return fewer series than the limit. [grounded: tree pkg/telemetrytraces/statement_builder.go] [consensus 5/5: valid=5]
minor
This asks for code reuse and logging. [consensus 5/5: minor=5]
uncertain
No path in the change supports variables in HAVING, and none existed before. This is a speculative feature gap. [uncertain: no evidence quoted] [consensus 4/5: uncertain=4, valid=1]
invalid
Before the change, Name already came from the `name` param, so behaviour is the same when it is missing. searchText is now the value search, so overwriting Name is correct. [invalid: contradiction] [consensus 5/5: invalid=5]
minor
This is a duplication concern. [consensus 5/5: minor=5]
minor
This is a duplication concern. [consensus 5/5: minor=5]
minor
This is about an unused field. [consensus 5/5: minor=5]
minor
This is a duplication concern. [consensus 5/5: minor=5]
raw comments (21)
pkg/telemetrytraces/const.go:18
<!-- cubic:v=9a8ce8c1-e55e-4948-87d9-967ea0a01f51 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":8} --> P1: Removing "timestamp" from `IntrinsicFields` leaves it in none of the four field lists, so `ConditionFor` no longer skips the default exists filter for timestamp predicates. Any positive operator on `timestamp` (Equal, GreaterThan, GreaterThanOrEq, LessThan, LessThanOrEq, Between, In) now emits an extra `timestamp != ''` predicate on a non-nullable DateTime64 column, and the existing expectations in `condition_builder_test.go` (e.g. `timestamp >= ?` for GreaterThanOrEq) no longer hold. Add `"timestamp"` to `IntrinsicFieldsDeprecated`, which the condition builder also consults, to restore the previous behavior while keeping it out of the key suggestions `telemetrymetadata` builds from `IntrinsicFields`. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrytraces/const.go, line 18: <comment>Removing "timestamp" from `IntrinsicFields` leaves it in none of the four field lists, so `ConditionFor` no longer skips the default exists filter for timestamp predicates. Any positive operator on `timestamp` (Equal, GreaterThan, GreaterThanOrEq, LessThan, LessThanOrEq, Between, In) now emits an extra `timestamp != ''` predicate on a non-nullable DateTime64 column, and the existing expectations in `condition_builder_test.go` (e.g. `timestamp >= ?` for GreaterThanOrEq) no longer hold. Add `"timestamp"` to `IntrinsicFieldsDeprecated`, which the condition builder also consults, to restore the previous behavior while keeping it out of the key suggestions `telemetrymetadata` builds from `IntrinsicFields`.</comment> <file context> @@ -15,6 +14,8 @@ var ( "status_message", "status_code_string", + } + IntrinsicFieldsDeprecated = []string{ "traceID", "spanID", </file context> ``` </details> ```suggestion IntrinsicFieldsDeprecated = []string{ "timestamp", ```
pkg/querybuilder/having_rewriter.go:111
<!-- cubic:v=73af5410-5b53-49bb-bc40-42f2600d33fc --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":8} --> P1: HAVING that references an aggregation expression containing a string literal is never rewritten, so the outer query gets invalid SQL. The quote masking runs on the expression first, turning `countIf(level='error')` into `countIf(level=__QUOTED_0__)`, while the map key stays `countIf(level='error')`, so the `\b`+QuotedMeta pattern cannot match and the raw function call leaks into the HAVING clause of the aggregated query. Apply the same literal-to-placeholder masking to `m.from` before matching, keyed by the literal text so both sides produce the same placeholder. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querybuilder/having_rewriter.go, line 111: <comment>HAVING that references an aggregation expression containing a string literal is never rewritten, so the outer query gets invalid SQL. The quote masking runs on the expression first, turning `countIf(level='error')` into `countIf(level=__QUOTED_0__)`, while the map key stays `countIf(level='error')`, so the `\b`+QuotedMeta pattern cannot match and the raw function call leaks into the HAVING clause of the aggregated query. Apply the same literal-to-placeholder masking to `m.from` before matching, keyed by the literal text so both sides produce the same placeholder.</comment> <file context> @@ -0,0 +1,153 @@ + quotePattern := regexp.MustCompile(`'[^']*'|"[^"]*"`) + quotedIdx := 0 + + expression = quotePattern.ReplaceAllStringFunc(expression, func(match string) string { + placeholder := fmt.Sprintf("__QUOTED_%d__", quotedIdx) + quotedStrings[placeholder] = match </file context> ``` </details>
pkg/querier/postprocess.go:457
<!-- cubic:v=ce8afaaf-c9af-4959-88a7-fc6a6f97c54b --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":7} --> P1: Group-by columns are derived only from `formulaSeries[0].Labels`, and each row's values are then written by position (`row[i] = label.Value`). When the evaluator returns series with different label sets or key order (as `findUniqueLabelSets` allows), label values are written under the wrong group column or lost. Build the label-to-column mapping by label key and look up each series' labels by that key instead of by index. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/postprocess.go, line 457: <comment>Group-by columns are derived only from `formulaSeries[0].Labels`, and each row's values are then written by position (`row[i] = label.Value`). When the evaluator returns series with different label sets or key order (as `findUniqueLabelSets` allows), label values are written under the wrong group column or lost. Build the label-to-column mapping by label key and look up each series' labels by that key instead of by index.</comment> <file context> @@ -278,12 +293,185 @@ func (q *querier) processTimeSeriesFormula( + + for i, label := range series.Labels { + if i < len(row)-1 { + row[i] = label.Value + } + } </file context> ``` </details>
pkg/querier/format.go:14
<!-- cubic:v=2c408575-8e08-4ffb-a272-e644a4d98202 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":7} --> P1: Both helpers receive a `qbv5.VariableItem` from their only callers and neither handles that type, so `{{var}}`/`[[var]]`/`$var` in promql and CH-SQL templates render as empty strings. The callers pass `v` from `map[string]qbtypes.VariableItem` (promql_query.go:66, clickhouse_query.go:66); pass `v.Value` at those call sites, or unwrap `VariableItem` here. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/format.go, line 14: <comment>Both helpers receive a `qbv5.VariableItem` from their only callers and neither handles that type, so `{{var}}`/`[[var]]`/`$var` in promql and CH-SQL templates render as empty strings. The callers pass `v` from `map[string]qbtypes.VariableItem` (promql_query.go:66, clickhouse_query.go:66); pass `v.Value` at those call sites, or unwrap `VariableItem` here.</comment> <file context> @@ -0,0 +1,181 @@ +} + +// formatValue formats the value to be used in clickhouse query +func formatValueForCH(v any) string { + // if it's pointer convert it to a value + v = getPointerValue(v) </file context> ``` </details>
pkg/querybuilder/where_clause_visitor.go:355
<!-- cubic:v=477af4d9-c3eb-4c07-8cae-8524648a4ce5 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P1: Returning `""` does not skip the condition when the comparison is combined with other conditions: `VisitAndExpression`/`VisitOrExpression` join the visited strings with `v.builder.And`/`Or`, so a dynamic variable set to `__all__` in `service.name IN ($service) AND http.status_code = 200` yields a malformed clause fragment (`... AND )`) and the query fails. Return the no-op sentinel used elsewhere for skipped filters (`VisitFullText` returns `"true"`). Note the scalar path has no `__all__` handling at all, so `code = $code` compares against the literal `__all__`. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querybuilder/where_clause_visitor.go, line 355: <comment>Returning `""` does not skip the condition when the comparison is combined with other conditions: `VisitAndExpression`/`VisitOrExpression` join the visited strings with `v.builder.And`/`Or`, so a dynamic variable set to `__all__` in `service.name IN ($service) AND http.status_code = 200` yields a malformed clause fragment (`... AND )`) and the query fails. Return the no-op sentinel used elsewhere for skipped filters (`VisitFullText` returns `"true"`). Note the scalar path has no `__all__` handling at all, so `code = $code` compares against the literal `__all__`.</comment> <file context> @@ -320,10 +323,46 @@ func (v *filterExpressionVisitor) VisitComparison(ctx *grammar.ComparisonContext + if varItem.Type == qbtypes.DynamicVariableType { + // check if it is special value to skip entire filter, if so skip it + if all_, ok := varItem.Value.(string); ok && all_ == "__all__" { + return "" + } + } </file context> ``` </details> ```suggestion return "true" ```
pkg/querybuilder/where_clause_visitor.go:433
<!-- cubic:v=086800e8-5c3b-40b5-a754-56e06c93bea9 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":5} --> P1: If a variable resolves to an empty list (`varItem.Value` is `[]any{}`, e.g. a dynamic/query variable with no values selected), `varValues[0]` panics with index out of range and the query fails. Guard the index access. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querybuilder/where_clause_visitor.go, line 433: <comment>If a variable resolves to an empty list (`varItem.Value` is `[]any{}`, e.g. a dynamic/query variable with no values selected), `varValues[0]` panics with index out of range and the query fails. Guard the index access.</comment> <file context> @@ -378,6 +417,26 @@ func (v *filterExpressionVisitor) VisitComparison(ctx *grammar.ComparisonContext + if ok { + switch varValues := varItem.Value.(type) { + case []any: + value = varValues[0] + case any: + value = varValues </file context> ``` </details>
pkg/telemetrymetadata/metadata.go:217
<!-- cubic:v=135a8b43-e290-4b14-9745-d4171718da1c --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":5} --> P2: `getTracesKeys` and `getLogsKeys` append the static intrinsic/calculated keys without checking whether the same name already came back from the fields-table query. When the fields table carries the row (tag_type `spanfield`/`logfield`, which the priority CASE and reader.go filters imply is possible), `GetKeys`/`GetKeysMulti` bucket two entries under the same name: the query-derived key with a real `FieldDataType`, plus a new one with `FieldDataType` unspecified. Dedupe against `keys` (or merge into the existing entry) before appending. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrymetadata/metadata.go, line 217: <comment>`getTracesKeys` and `getLogsKeys` append the static intrinsic/calculated keys without checking whether the same name already came back from the fields-table query. When the fields table carries the row (tag_type `spanfield`/`logfield`, which the priority CASE and reader.go filters imply is possible), `GetKeys`/`GetKeysMulti` bucket two entries under the same name: the query-derived key with a real `FieldDataType`, plus a new one with `FieldDataType` unspecified. Dedupe against `keys` (or merge into the existing entry) before appending.</comment> <file context> @@ -207,6 +214,28 @@ func (t *telemetryMetaStore) getTracesKeys(ctx context.Context, fieldKeySelector return nil, errors.Wrapf(rows.Err(), errors.TypeInternal, errors.CodeInternal, ErrFailedToGetTracesKeys.Error()) } + staticKeys := []string{"isRoot", "isEntrypoint"} + staticKeys = append(staticKeys, telemetrytraces.IntrinsicFields...) + staticKeys = append(staticKeys, telemetrytraces.CalculatedFields...) </file context> ``` </details>
pkg/querier/promql_query.go:44
<!-- cubic:v=db2a293a-902a-4fd5-bb2b-fe34da4cdc2d --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P2: `Fingerprint()` now renders the query with the request window, so any query referencing a reserved time variable gets a different fingerprint on every request window. The bucket cache key is built only from the fingerprint (`bucket_cache.go` `generateCacheKey` -> `v5:query:%s`), so these queries never reuse stored buckets and every refresh writes a new cache entry. Render with a time-independent start/end (or exclude reserved vars) when computing the fingerprint. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/promql_query.go, line 44: <comment>`Fingerprint()` now renders the query with the request window, so any query referencing a reserved time variable gets a different fingerprint on every request window. The bucket cache key is built only from the fingerprint (`bucket_cache.go` `generateCacheKey` -> `v5:query:%s`), so these queries never reuse stored buckets and every refresh writes a new cache entry. Render with a time-independent start/end (or exclude reserved vars) when computing the fingerprint.</comment> <file context> @@ -14,27 +19,36 @@ import ( } func (q *promqlQuery) Fingerprint() string { + query, err := q.renderVars(q.query.Query, q.vars, q.tr.From, q.tr.To) + if err != nil { + q.logger.ErrorContext(context.TODO(), "failed render template variables", "query", q.query.Query) </file context> ``` </details> ```suggestion query, err := q.renderVars(q.query.Query, q.vars, 0, 0) ```
pkg/querier/postprocess.go:231
<!-- cubic:v=5ef5a698-339f-4da0-8351-1c7ac303a67e --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":9} --> P2: `applySeriesLimit` only handles `*qbtypes.TimeSeriesData` and returns early for anything else, but `processScalarFormula` always returns `*qbtypes.ScalarData`. This line therefore never limits anything, so `formula.Limit`/`formula.Order` is silently ignored for scalar requests. Either drop the call or implement row limiting for scalar formula results. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/postprocess.go, line 231: <comment>`applySeriesLimit` only handles `*qbtypes.TimeSeriesData` and returns early for anything else, but `processScalarFormula` always returns `*qbtypes.ScalarData`. This line therefore never limits anything, so `formula.Limit`/`formula.Order` is silently ignored for scalar requests. Either drop the call or implement row limiting for scalar formula results.</comment> <file context> @@ -220,6 +228,13 @@ func (q *querier) applyFormulas(ctx context.Context, results map[string]*qbtypes if req.RequestType == qbtypes.RequestTypeTimeSeries { result := q.processTimeSeriesFormula(ctx, results, formula, req) if result != nil { + result = q.applySeriesLimit(result, formula.Limit, formula.Order) + results[name] = result + } </file context> ``` </details>
pkg/telemetrylogs/const.go:14
<!-- cubic:v=19641078-b0f9-4e0a-aa57-2f96e7fe3628 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P2: Removing "timestamp" from IntrinsicFields silently changes two behaviors. First, getLogsKeys (pkg/telemetrymetadata/metadata.go:371) builds its static key list only from IntrinsicFields, so "timestamp" is no longer returned as a log field key to clients/UI field pickers. Second, the exists handling in pkg/telemetrylogs/condition_builder.go:151/213 no longer short-circuits for timestamp: `timestamp exists` now emits `timestamp != 0` instead of `true`, and every `timestamp = ...`/range filter gets an extra `timestamp != 0 AND ...` exists clause. If timestamp was dropped deliberately, ignore this; otherwise restore it so the log field list and exists-filter behavior stay unchanged. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrylogs/const.go, line 14: <comment>Removing "timestamp" from IntrinsicFields silently changes two behaviors. First, getLogsKeys (pkg/telemetrymetadata/metadata.go:371) builds its static key list only from IntrinsicFields, so "timestamp" is no longer returned as a log field key to clients/UI field pickers. Second, the exists handling in pkg/telemetrylogs/condition_builder.go:151/213 no longer short-circuits for timestamp: `timestamp exists` now emits `timestamp != 0` instead of `true`, and every `timestamp = ...`/range filter gets an extra `timestamp != 0 AND ...` exists clause. If timestamp was dropped deliberately, ignore this; otherwise restore it so the log field list and exists-filter behavior stay unchanged.</comment> <file context> @@ -10,5 +10,7 @@ var ( BodyJSONStringSearchPrefix = `body.` - IntrinsicFields = []string{"timestamp", "body", "trace_id", "span_id", "trace_flags", "severity_text", "severity_number"} + IntrinsicFields = []string{ + "body", "trace_id", "span_id", "trace_flags", "severity_text", "severity_number", "scope_name", "scope_version", + } ) </file context> ``` </details> ```suggestion "timestamp", "body", "trace_id", "span_id", "trace_flags", "severity_text", "severity_number", "scope_name", "scope_version", ```
pkg/telemetrylogs/condition_builder_test.go:84
<!-- cubic:v=4f2bde2a-399c-45ad-9387-87a10a23409b --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":8} --> P2: These timestamp-operator cases are deleted instead of updated, which hides a behavior change and drops coverage. `timestamp` is not in `IntrinsicFields`, so `ConditionFor` now wraps the positive exists-filter operators (GreaterThanOrEq, LessThanOrEq, Between) with an additional `timestamp <> 0` exists clause (AddDefaultExistsFilter returns true, and timestamp is a UInt64 col), and numeric Exists now returns `timestamp <> 0` instead of `true`. The deleted GE/LE/Between/Exists cases would simply fail against the new SQL, and the NotEqual/NotBetween/Between-error cases still pass but are removed too. Update the expectedSQL/expectedArgs to lock in the new conditions and keep the cases, rather than deleting them; otherwise a regression in the exists-filter wrapping or numeric exists branch goes uncaught. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrylogs/condition_builder_test.go, line 84: <comment>These timestamp-operator cases are deleted instead of updated, which hides a behavior change and drops coverage. `timestamp` is not in `IntrinsicFields`, so `ConditionFor` now wraps the positive exists-filter operators (GreaterThanOrEq, LessThanOrEq, Between) with an additional `timestamp <> 0` exists clause (AddDefaultExistsFilter returns true, and timestamp is a UInt64 col), and numeric Exists now returns `timestamp <> 0` instead of `true`. The deleted GE/LE/Between/Exists cases would simply fail against the new SQL, and the NotEqual/NotBetween/Between-error cases still pass but are removed too. Update the expectedSQL/expectedArgs to lock in the new conditions and keep the cases, rather than deleting them; otherwise a regression in the exists-filter wrapping or numeric exists branch goes uncaught.</comment> <file context> @@ -35,18 +35,6 @@ func TestConditionFor(t *testing.T) { expectedArgs: []any{"error message"}, expectedError: nil, }, - { - name: "Not Equal operator - timestamp", - key: telemetrytypes.TelemetryFieldKey{ - Name: "timestamp", - FieldContext: telemetrytypes.FieldContextLog, - }, </file context> ``` </details>
grammar/FilterQuery.g4:82
<!-- cubic:v=0052b647-7dfa-47bb-bcb8-d01f8fc0b42b --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P2: A bare word followed by the word "in" now silently becomes an IN filter: `error in production` parses as key `error` IN value `production` instead of the previous parse failure / bare-text handling. `value` includes `KEY`, so any bare token is accepted after IN and the preceding token becomes a comparison key. If a text search contains the word "in" (e.g. `request in cache` with a real field name before it), the query silently filters on that field instead of matching text, returning wrong results rather than an error. Restrict the new alternative to values that cannot be plain words (variables/`$`-prefixed or quoted values) so bare-text queries keep their previous meaning. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At grammar/FilterQuery.g4, line 82: <comment>A bare word followed by the word "in" now silently becomes an IN filter: `error in production` parses as key `error` IN value `production` instead of the previous parse failure / bare-text handling. `value` includes `KEY`, so any bare token is accepted after IN and the preceding token becomes a comparison key. If a text search contains the word "in" (e.g. `request in cache` with a real field name before it), the query silently filters on that field instead of matching text, returning wrong results rather than an error. Restrict the new alternative to values that cannot be plain words (variables/`$`-prefixed or quoted values) so bare-text queries keep their previous meaning.</comment> <file context> @@ -79,11 +79,13 @@ comparison inClause : IN LPAREN valueList RPAREN | IN LBRACK valueList RBRACK + | IN value ; </file context> ``` </details>
pkg/telemetrytraces/statement_builder.go:303
<!-- cubic:v=6cb06969-e59d-4b9c-82f1-703b680c5ff4 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P2: Passing skipHaving=true to the CTE call removes HAVING from `__limit_cte`, so a top/bottom-N panel that also sets a having clause now picks its N series by the aggregate first and drops the ones failing HAVING in the outer query. Such panels return fewer series than the limit (sometimes none) even when other groups satisfy HAVING, whereas the limit used to be applied after the having filter. Pass `false` for skipHaving here and in the CTE call inside buildScalarQuery (line 423 keeps the rewriter, so the rewritten expression is valid there too). <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrytraces/statement_builder.go, line 303: <comment>Passing skipHaving=true to the CTE call removes HAVING from `__limit_cte`, so a top/bottom-N panel that also sets a having clause now picks its N series by the aggregate first and drops the ones failing HAVING in the outer query. Such panels return fewer series than the limit (sometimes none) even when other groups satisfy HAVING, whereas the limit used to be applied after the having filter. Pass `false` for skipHaving here and in the CTE call inside buildScalarQuery (line 423 keeps the rewriter, so the rewritten expression is valid there too).</comment> <file context> @@ -300,7 +300,7 @@ func (b *traceQueryStatementBuilder) buildTimeSeriesQuery( // build the scalar “top/bottom-N” query in its own builder. cteSB := sqlbuilder.NewSelectBuilder() - cteStmt, err := b.buildScalarQuery(ctx, cteSB, query, start, end, keys, true, variables) + cteStmt, err := b.buildScalarQuery(ctx, cteSB, query, start, end, keys, variables, true, true) if err != nil { return nil, err </file context> ``` </details> ```suggestion cteStmt, err := b.buildScalarQuery(ctx, cteSB, query, start, end, keys, variables, true, false) ```
pkg/querier/format.go:13
<!-- cubic:v=4c3aa4dc-2709-46b7-a106-32580cdff14e --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":7} --> P2: This file re-implements `utils.ClickHouseFormattedValue`/`utils.QuoteEscapedString` (pkg/query-service/utils/format.go) and `metrics.PromFormattedValue` (pkg/query-service/app/metrics/query_builder.go:124), but the copies drop the `zap.L().Error(...)` calls in the default branches. Unsupported types now return an empty string with no diagnostic. Share one implementation, or keep the logging. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/format.go, line 13: <comment>This file re-implements `utils.ClickHouseFormattedValue`/`utils.QuoteEscapedString` (pkg/query-service/utils/format.go) and `metrics.PromFormattedValue` (pkg/query-service/app/metrics/query_builder.go:124), but the copies drop the `zap.L().Error(...)` calls in the default branches. Unsupported types now return an empty string with no diagnostic. Share one implementation, or keep the logging.</comment> <file context> @@ -0,0 +1,181 @@ + return fmt.Sprintf("[%s]", strings.Join(strs, ",")) +} + +// formatValue formats the value to be used in clickhouse query +func formatValueForCH(v any) string { + // if it's pointer convert it to a value </file context> ``` </details>
pkg/telemetrymetrics/statement_builder.go:509
<!-- cubic:v=c01c8a67-5f71-44d9-b759-0e5a1d8f8167 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":5} --> P2: HAVING expressions reach ClickHouse without variable substitution, so a dashboard variable in a having clause (e.g. `max(http_requests) > $threshold`) is emitted literally as `$threshold` and the query fails. The rewriter only maps aggregation names to the `value` column; pass the variables map through the same substitution path used for the filter expression (see the `Variables: variables` added in `buildTimeSeriesCTE`). Note both branches in `buildFinalSelect` are affected. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrymetrics/statement_builder.go, line 509: <comment>HAVING expressions reach ClickHouse without variable substitution, so a dashboard variable in a having clause (e.g. `max(http_requests) > $threshold`) is emitted literally as `$threshold` and the query fails. The rewriter only maps aggregation names to the `value` column; pass the variables map through the same substitution path used for the filter expression (see the `Variables: variables` added in `buildTimeSeriesCTE`). Note both branches in `buildFinalSelect` are affected.</comment> <file context> @@ -499,9 +504,19 @@ func (b *metricQueryStatementBuilder) buildFinalSelect( sb.GroupBy("ts") + if query.Having != nil && query.Having.Expression != "" { + rewriter := querybuilder.NewHavingExpressionRewriter() + rewrittenExpr := rewriter.RewriteForMetrics(query.Having.Expression, query.Aggregations) + sb.Having(rewrittenExpr) + } </file context> ``` </details>
pkg/apis/fields/parse.go:96
<!-- cubic:v=5bef566a-c4d8-4cc4-a5a0-d528b23749f2 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P2: The new `keySelector.Name = name` overwrites the Name that parseFieldKeyRequest already set from `searchText`. When the caller omits the `name` query param, Name becomes empty and the value query no longer filters by tag key (metadata.go applies that filter only when `Name != ""`), silently returning unfiltered values from every field. Only override Name when the `name` param is present, or validate that it is provided. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/apis/fields/parse.go, line 96: <comment>The new `keySelector.Name = name` overwrites the Name that parseFieldKeyRequest already set from `searchText`. When the caller omits the `name` query param, Name becomes empty and the value query no longer filters by tag key (metadata.go applies that filter only when `Name != ""`), silently returning unfiltered values from every field. Only override Name when the `name` param is present, or validate that it is provided.</comment> <file context> @@ -92,8 +92,10 @@ func parseFieldValueRequest(r *http.Request) (*telemetrytypes.FieldValueSelector } + name := r.URL.Query().Get("name") + keySelector.Name = name existingQuery := r.URL.Query().Get("existingQuery") - value := r.URL.Query().Get("value") </file context> ``` </details>
pkg/querybuilder/time.go:1
<!-- cubic:v=258d4c83-5843-458a-b2e8-380fda68a6f9 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":6} --> P3: AssignReservedVars re-implements the exact key/unit mapping already implemented by AssignReservedVarsV3 (pkg/query-service/utils/queryTemplate/vars.go:11). Both paths stay live, so a future unit change in one of them will silently diverge the v3 and v5 templating. Have AssignReservedVarsV3 delegate to this function, or have both share the mapping (the canonical key list already exists as variables.ReservedTimeVars). <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querybuilder/time.go, line 90: <comment>AssignReservedVars re-implements the exact key/unit mapping already implemented by AssignReservedVarsV3 (pkg/query-service/utils/queryTemplate/vars.go:11). Both paths stay live, so a future unit change in one of them will silently diverge the v3 and v5 templating. Have AssignReservedVarsV3 delegate to this function, or have both share the mapping (the canonical key list already exists as variables.ReservedTimeVars).</comment> <file context> @@ -83,3 +86,19 @@ func MinAllowedStepIntervalForMetric(start, end uint64) uint64 { return step - step%60 } + +func AssignReservedVars(vars map[string]any, start, end uint64) { + start = ToNanoSecs(start) + end = ToNanoSecs(end) </file context> ``` </details>
pkg/querier/promql_query.go:63
<!-- cubic:v=4edecf84-12e1-4f0c-8def-6302c3eee123 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":8} --> P3: `renderVars` is a line-for-line copy of `chSQLQuery.renderVars` (pkg/querier/clickhouse_query.go:63) — same var seeding, same reserved-var assignment, same length-desc sort, same three `strings.Replace` passes, same text/template parse+execute; only `formatValueForProm` vs `formatValueForCH` and the template name differ. Extract one shared helper parameterized by the value formatter and template name so future template fixes touch a single place. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/promql_query.go, line 63: <comment>`renderVars` is a line-for-line copy of `chSQLQuery.renderVars` (pkg/querier/clickhouse_query.go:63) — same var seeding, same reserved-var assignment, same length-desc sort, same three `strings.Replace` passes, same text/template parse+execute; only `formatValueForProm` vs `formatValueForCH` and the template name differ. Extract one shared helper parameterized by the value formatter and template name so future template fixes touch a single place.</comment> <file context> @@ -45,23 +59,66 @@ func (q *promqlQuery) Window() (uint64, uint64) { } +// TODO(srikanthccv): cleanup the templating logic +func (q *promqlQuery) renderVars(query string, vars map[string]qbv5.VariableItem, start, end uint64) (string, error) { + varsData := map[string]any{} + for k, v := range vars { </file context> ``` </details>
pkg/querier/clickhouse_query.go:21
<!-- cubic:v=dfdd1731-f543-4217-8f4d-95522b97a0e6 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":8} --> P3: The new `logger` field is written in the constructor but never read anywhere in this file (no method uses `q.logger`), so the added constructor parameter has no effect. Either use it, e.g. to log a failed `renderVars` in `Fingerprint` as promqlQuery does, or drop the field and parameter. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/querier/clickhouse_query.go, line 21: <comment>The new `logger` field is written in the constructor but never read anywhere in this file (no method uses `q.logger`), so the added constructor parameter has no effect. Either use it, e.g. to log a failed `renderVars` in `Fingerprint` as promqlQuery does, or drop the field and parameter.</comment> <file context> @@ -1,40 +1,54 @@ ) type chSQLQuery struct { + logger *slog.Logger telemetryStore telemetrystore.TelemetryStore </file context> ``` </details>
pkg/telemetrylogs/statement_builder.go:278
<!-- cubic:v=9a0ab29a-0a38-4567-aa41-130ad97aed49 --> <!-- cubic:review-run=4178e2a1-8ca6-5a97-97bc-42a7d521d205 --> <!-- metadata:{"confidence":7} --> P3: The HAVING rewrite block is now duplicated in three places in this file (lines 279-281, 295-297, 387-389). Extract it into a small helper (e.g. `b.rewriteHaving(query)`) so a future change to the rewriter stays consistent across the list, time-series, and scalar paths. <details> <summary>Prompt for AI agents</summary> ```text Check if this issue is valid — if so, understand the root cause and fix it. At pkg/telemetrylogs/statement_builder.go, line 278: <comment>The HAVING rewrite block is now duplicated in three places in this file (lines 279-281, 295-297, 387-389). Extract it into a small helper (e.g. `b.rewriteHaving(query)`) so a future change to the rewriter stays consistent across the list, time-series, and scalar paths.</comment> <file context> @@ -275,7 +275,10 @@ func (b *logQueryStatementBuilder) buildTimeSeriesQuery( sb.GroupBy("ALL") if query.Having != nil && query.Having.Expression != "" { - sb.Having(query.Having.Expression) + // Rewrite having expression to use SQL column names + rewriter := querybuilder.NewHavingExpressionRewriter() + rewrittenExpr := rewriter.RewriteForLogs(query.Having.Expression, query.Aggregations) </file context> ``` </details>
PR-level
<!-- cubic:review-summary:start --> **20 issues found** across 27 files <!-- cubic:review-summary:end --> <details> <summary>Prompt for AI agents (unresolved issues)</summary> ```text Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately. <file name="pkg/telemetrymetadata/metadata.go"> <violation number="1" location="pkg/telemetrymetadata/metadata.go:217"> P2: `getTracesKeys` and `getLogsKeys` append the static intrinsic/calculated keys without checking whether the same name already came back from the fields-table query. When the fields table carries the row (tag_type `spanfield`/`logfield`, which the priority CASE and reader.go filters imply is possible), `GetKeys`/`GetKeysMulti` bucket two entries under the same name: the query-derived key with a real `FieldDataType`, plus a new one with `FieldDataType` unspecified. Dedupe against `keys` (or merge into the existing entry) before appending.</violation> </file> <file name="pkg/querybuilder/time.go"> <violation number="1" location="pkg/querybuilder/time.go:90"> P3: AssignReservedVars re-implements the exact key/unit mapping already implemented by AssignReservedVarsV3 (pkg/query-service/utils/queryTemplate/vars.go:11). Both paths stay live, so a future unit change in one of them will silently diverge the v3 and v5 templating. Have AssignReservedVarsV3 delegate to this function, or have both share the mapping (the canonical key list already exists as variables.ReservedTimeVars).</violation> </file> <file name="pkg/querier/promql_query.go"> <violation number="1" location="pkg/querier/promql_query.go:44"> P2: `Fingerprint()` now renders the query with the request window, so any query referencing a reserved time variable gets a different fingerprint on every request window. The bucket cache key is built only from the fingerprint (`bucket_cache.go` `generateCacheKey` -> `v5:query:%s`), so these queries never reuse stored buckets and every refresh writes a new cache entry. Render with a time-independent start/end (or exclude reserved vars) when computing the fingerprint.</violation> <violation number="2" location="pkg/querier/promql_query.go:63"> P3: `renderVars` is a line-for-line copy of `chSQLQuery.renderVars` (pkg/querier/clickhouse_query.go:63) — same var seeding, same reserved-var assignment, same length-desc sort, same three `strings.Replace` passes, same text/template parse+execute; only `formatValueForProm` vs `formatValueForCH` and the template name differ. Extract one shared helper parameterized by the value formatter and template name so future template fixes touch a single place.</violation> </file> <file name="pkg/telemetrytraces/const.go"> <violation number="1" location="pkg/telemetrytraces/const.go:18"> P1: Removing "timestamp" from `IntrinsicFields` leaves it in none of the four field lists, so `ConditionFor` no longer skips the default exists filter for timestamp predicates. Any positive operator on `timestamp` (Equal, GreaterThan, GreaterThanOrEq, LessThan, LessThanOrEq, Between, In) now emits an extra `timestamp != ''` predicate on a non-nullable DateTime64 column, and the existing expectations in `condition_builder_test.go` (e.g. `timestamp >= ?` for GreaterThanOrEq) no longer hold. Add `"timestamp"` to `IntrinsicFieldsDeprecated`, which the condition builder also consults, to restore the previous behavior while keeping it out of the key suggestions `telemetrymetadata` builds from `IntrinsicFields`.</violation> </file> <file name="pkg/querybuilder/having_rewriter.go"> <violation number="1" location="pkg/querybuilder/having_rewriter.go:111"> P1: HAVING that references an aggregation expression containing a string literal is never rewritten, so the outer query gets invalid SQL. The quote masking runs on the expression first, turning `countIf(level='error')` into `countIf(level=__QUOTED_0__)`, while the map key stays `countIf(level='error')`, so the `\b`+QuotedMeta pattern cannot match and the raw function call leaks into the HAVING clause of the aggregated query. Apply the same literal-to-placeholder masking to `m.from` before matching, keyed by the literal text so both sides produce the same placeholder.</violation> </file> <file name="pkg/querier/postprocess.go"> <violation number="1" location="pkg/querier/postprocess.go:231"> P2: `applySeriesLimit` only handles `*qbtypes.TimeSeriesData` and returns early for anything else, but `processScalarFormula` always returns `*qbtypes.ScalarData`. This line therefore never limits anything, so `formula.Limit`/`formula.Order` is silently ignored for scalar requests. Either drop the call or implement row limiting for scalar formula results.</violation> <violation number="2" location="pkg/querier/postprocess.go:457"> P1: Group-by columns are derived only from `formulaSeries[0].Labels`, and each row's values are then written by position (`row[i] = label.Value`). When the evaluator returns series with different label sets or key order (as `findUniqueLabelSets` allows), label values are written under the wrong group column or lost. Build the label-to-column mapping by label key and look up each series' labels by that key instead of by index.</violation> </file> <file name="pkg/telemetrylogs/const.go"> <violation number="1" location="pkg/telemetrylogs/const.go:14"> P2: Removing "timestamp" from IntrinsicFields silently changes two behaviors. First, getLogsKeys (pkg/telemetrymetadata/metadata.go:371) builds its static key list only from IntrinsicFields, so "timestamp" is no longer returned as a log field key to clients/UI field pickers. Second, the exists handling in pkg/telemetrylogs/condition_builder.go:151/213 no longer short-circuits for timestamp: `timestamp exists` now emits `timestamp != 0` instead of `true`, and every `timestamp = ...`/range filter gets an extra `timestamp != 0 AND ...` exists clause. If timestamp was dropped deliberately, ignore this; otherwise restore it so the log field list and exists-filter behavior stay unchanged.</violation> </file> <file name="pkg/querier/clickhouse_query.go"> <violation number="1" location="pkg/querier/clickhouse_query.go:21"> P3: The new `logger` field is written in the constructor but never read anywhere in this file (no method uses `q.logger`), so the added constructor parameter has no effect. Either use it, e.g. to log a failed `renderVars` in `Fingerprint` as promqlQuery does, or drop the field and parameter.</violation> </file> <file name="pkg/telemetrylogs/condition_builder_test.go"> <violation number="1" location="pkg/telemetrylogs/condition_builder_test.go:84"> P2: These timestamp-operator cases are deleted instead of updated, which hides a behavior change and drops coverage. `timestamp` is not in `IntrinsicFields`, so `ConditionFor` now wraps the positive exists-filter operators (GreaterThanOrEq, LessThanOrEq, Between) with an additional `timestamp <> 0` exists clause (AddDefaultExistsFilter returns true, and timestamp is a UInt64 col), and numeric Exists now returns `timestamp <> 0` instead of `true`. The deleted GE/LE/Between/Exists cases would simply fail against the new SQL, and the NotEqual/NotBetween/Between-error cases still pass but are removed too. Update the expectedSQL/expectedArgs to lock in the new conditions and keep the cases, rather than deleting them; otherwise a regression in the exists-filter wrapping or numeric exists branch goes uncaught.</violation> </file> <file name="grammar/FilterQuery.g4"> <violation number="1" location="grammar/FilterQuery.g4:82"> P2: A bare word followed by the word "in" now silently becomes an IN filter: `error in production` parses as key `error` IN value `production` instead of the previous parse failure / bare-text handling. `value` includes `KEY`, so any bare token is accepted after IN and the preceding token becomes a comparison key. If a text search contains the word "in" (e.g. `request in cache` with a real field name before it), the query silently filters on that field instead of matching text, returning wrong results rather than an error. Restrict the new alternative to values that cannot be plain words (variables/`$`-prefixed or quoted values) so bare-text queries keep their previous meaning.</violation> </file> <file name="pkg/telemetrytraces/statement_builder.go"> <violation number="1" location="pkg/telemetrytraces/statement_builder.go:303"> P2: Passing skipHaving=true to the CTE call removes HAVING from `__limit_cte`, so a top/bottom-N panel that also sets a having clause now picks its N series by the aggregate first and drops the ones failing HAVING in the outer query. Such panels return fewer series than the limit (sometimes none) even when other groups satisfy HAVING, whereas the limit used to be applied after the having filter. Pass `false` for skipHaving here and in the CTE call inside buildScalarQuery (line 423 keeps the rewriter, so the rewritten expression is valid there too).</violation> </file> <file name="pkg/telemetrylogs/statement_builder.go"> <violation number="1" location="pkg/telemetrylogs/statement_builder.go:278"> P3: The HAVING rewrite block is now duplicated in three places in this file (lines 279-281, 295-297, 387-389). Extract it into a small helper (e.g. `b.rewriteHaving(query)`) so a future change to the rewriter stays consistent across the list, time-series, and scalar paths.</violation> </file> <file name="pkg/querier/format.go"> <violation number="1" location="pkg/querier/format.go:13"> P2: This file re-implements `utils.ClickHouseFormattedValue`/`utils.QuoteEscapedString` (pkg/query-service/utils/format.go) and `metrics.PromFormattedValue` (pkg/query-service/app/metrics/query_builder.go:124), but the copies drop the `zap.L().Error(...)` calls in the default branches. Unsupported types now return an empty string with no diagnostic. Share one implementation, or keep the logging.</violation> <violation number="2" location="pkg/querier/format.go:14"> P1: Both helpers receive a `qbv5.VariableItem` from their only callers and neither handles that type, so `{{var}}`/`[[var]]`/`$var` in promql and CH-SQL templates render as empty strings. The callers pass `v` from `map[string]qbtypes.VariableItem` (promql_query.go:66, clickhouse_query.go:66); pass `v.Value` at those call sites, or unwrap `VariableItem` here.</violation> </file> <file name="pkg/telemetrymetrics/statement_builder.go"> <violation number="1" location="pkg/telemetrymetrics/statement_builder.go:509"> P2: HAVING expressions reach ClickHouse without variable substitution, so a dashboard variable in a having clause (e.g. `max(http_requests) > $threshold`) is emitted literally as `$threshold` and the query fails. The rewriter only maps aggregation names to the `value` column; pass the variables map through the same substitution path used for the filter expression (see the `Variables: variables` added in `buildTimeSeriesCTE`). Note both branches in `buildFinalSelect` are affected.</violation> </file> <file name="pkg/querybuilder/where_clause_visitor.go"> <violation number="1" location="pkg/querybuilder/where_clause_visitor.go:355"> P1: Returning `""` does not skip the condition when the comparison is combined with other conditions: `VisitAndExpression`/`VisitOrExpression` join the visited strings with `v.builder.And`/`Or`, so a dynamic variable set to `__all__` in `service.name IN ($service) AND http.status_code = 200` yields a malformed clause fragment (`... AND )`) and the query fails. Return the no-op sentinel used elsewhere for skipped filters (`VisitFullText` returns `"true"`). Note the scalar path has no `__all__` handling at all, so `code = $code` compares against the literal `__all__`.</violation> <violation number="2" location="pkg/querybuilder/where_clause_visitor.go:433"> P1: If a variable resolves to an empty list (`varItem.Value` is `[]any{}`, e.g. a dynamic/query variable with no values selected), `varValues[0]` panics with index out of range and the query fails. Guard the index access.</violation> </file> <file name="pkg/apis/fields/parse.go"> <violation number="1" location="pkg/apis/fields/parse.go:96"> P2: The new `keySelector.Name = name` overwrites the Name that parseFieldKeyRequest already set from `searchText`. When the caller omits the `name` query param, Name becomes empty and the value query no longer filters by tag key (metadata.go applies that filter only when `Name != ""`), silently returning unfiltered values from every field. Only override Name when the `name` param is present, or validate that it is provided.</violation> </file> ``` </details> <sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/78/ai_pr_review_github_delivery_98e8c5ffc5dd554ea85921516cd91d65ed252a920601718b2ca2b579ec415e0d?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F78)</sub> <!-- cubic:review-post:ai_pr_review_github_delivery_98e8c5ffc5dd554ea85921516cd91d65ed252a920601718b2ca2b579ec415e0d:e36699e3d4900194cd4ec7c03016ae7992aada0b:4178e2a1-8ca6-5a97-97bc-42a7d521d205 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ exact
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✗ —
d9 high ✓ exact
valid · matches d3 · impact high
valid · matches d2 · impact high
valid · matches d4 · impact high
valid · impact low
The change added a skipHaving flag to the traces buildScalarQuery and passes true for the limit CTE. The logs builder's limit CTE call has no such flag, and its buildScalarQuery still applies the rewritten HAVING. So logs filter the top-N groups on whole-range aggregates while traces don't. That leaves the two builders inconsistent: an incomplete change across sibling constructs. [grounded: tree pkg/telemetrylogs/statement_builder.go] [consensus 5/5: valid=5]
raw comments (5)
pkg/querier/clickhouse_query.go:66
### Template variables render as empty **High Severity** <!-- DESCRIPTION START --> `renderVars` passes each `VariableItem` struct into `formatValueForCH` and `formatValueForProm`, which only handle primitives and slices. The struct hits the default branch and becomes an empty string, so dashboard variables in ClickHouse and PromQL queries are replaced with nothing. Reserved time vars still work because they are assigned separately. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 23189e37-39fd-4d8d-8955-7e01994e8321 --> <!-- LOCATIONS START pkg/querier/clickhouse_query.go#L64-L66 pkg/querier/promql_query.go#L64-L66 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`pkg/querier/promql_query.go#L64-L66`](https://github.com/drape-io/crbench-cursor-2026-09/blob/fc3477bdd83f48ff2dd18541e8d4983c6e824d78/pkg/querier/promql_query.go#L64-L66) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRlYWY2MmYyLWQ1YzItNDQ5ZS1hYTMwLWI2ODU5M2Q1ZjY4OSIsImVuY3J5cHRpb25LZXkiOiJfaXNicUZrRkc2M2ZJNjNtME5fODJsVHpxR3dwVHFGSlg4YWNlMDVDLXI4IiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRlYWY2MmYyLWQ1YzItNDQ5ZS1hYTMwLWI2ODU5M2Q1ZjY4OSIsImVuY3J5cHRpb25LZXkiOiJfaXNicUZrRkc2M2ZJNjNtME5fODJsVHpxR3dwVHFGSlg4YWNlMDVDLXI4IiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjo4MCwiY29tbWl0U2hhIjoiZmMzNDc3YmRkODNmNDhmZjJkZDE4NTQxZThkNDk4M2M2ZTgyNGQ3OCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fc3477bdd83f48ff2dd18541e8d4983c6e824d78. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
pkg/querybuilder/where_clause_visitor.go:347
### Empty filter value panics lookup **High Severity** <!-- DESCRIPTION START --> When a comparison or `IN` value is an empty string, variable resolution always slices with `var_[1:]` after a failed map lookup. In Go that panics on a zero-length string, so filters such as `field = ''` or `field IN ''` crash the request instead of building a valid condition. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: e4aa6c1f-6ca2-41f0-a320-a722357daf13 --> <!-- LOCATIONS START pkg/querybuilder/where_clause_visitor.go#L345-L347 pkg/querybuilder/where_clause_visitor.go#L425-L427 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`pkg/querybuilder/where_clause_visitor.go#L425-L427`](https://github.com/drape-io/crbench-cursor-2026-09/blob/fc3477bdd83f48ff2dd18541e8d4983c6e824d78/pkg/querybuilder/where_clause_visitor.go#L425-L427) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjFmMzA5MGMyLTUwMTYtNDMwZC04NzkwLTI5OTdmMDdkOWVmOSIsImVuY3J5cHRpb25LZXkiOiJrQ3dWR2dvTGJweGVmemZDSTk3NG1EWjVXUVQtanVORlI0aEcxRjZsdjJFIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjFmMzA5MGMyLTUwMTYtNDMwZC04NzkwLTI5OTdmMDdkOWVmOSIsImVuY3J5cHRpb25LZXkiOiJrQ3dWR2dvTGJweGVmemZDSTk3NG1EWjVXUVQtanVORlI0aEcxRjZsdjJFIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjo4MCwiY29tbWl0U2hhIjoiZmMzNDc3YmRkODNmNDhmZjJkZDE4NTQxZThkNDk4M2M2ZTgyNGQ3OCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fc3477bdd83f48ff2dd18541e8d4983c6e824d78. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
pkg/querybuilder/where_clause_visitor.go:433
### Empty variable list panics equality **High Severity** <!-- DESCRIPTION START --> For non-`IN` comparisons, a list-valued variable is reduced with `varValues[0]` and there is no empty-length check. A multi-select (or dynamic) variable whose value is an empty slice panics instead of skipping or applying the filter. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 50bb7387-3bf9-46e5-9cc2-40299393d551 --> <!-- LOCATIONS START pkg/querybuilder/where_clause_visitor.go#L430-L433 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMwNTg1NjljLWZiNmYtNDdkNC04ZDk1LWFjMTkxODU0NDk3MiIsImVuY3J5cHRpb25LZXkiOiJlMDJBVlctaGFJYWVHNHZ0RWJJcHhVZ2YyS0V0S2s0UG5XZjVLZU9pbXBRIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmMwNTg1NjljLWZiNmYtNDdkNC04ZDk1LWFjMTkxODU0NDk3MiIsImVuY3J5cHRpb25LZXkiOiJlMDJBVlctaGFJYWVHNHZ0RWJJcHhVZ2YyS0V0S2s0UG5XZjVLZU9pbXBRIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjo4MCwiY29tbWl0U2hhIjoiZmMzNDc3YmRkODNmNDhmZjJkZDE4NTQxZThkNDk4M2M2ZTgyNGQ3OCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fc3477bdd83f48ff2dd18541e8d4983c6e824d78. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
pkg/telemetrylogs/statement_builder.go:252
### Logs limit CTE still applies HAVING **Medium Severity** <!-- DESCRIPTION START --> Traces now build the top-N limit CTE with `skipHaving` set so HAVING is applied only on the outer time-series query. Logs still run HAVING inside `buildScalarQuery` when constructing that CTE, so log queries with both a limit and a having clause pick a different top-N set than traces. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 809aa391-a592-4975-a094-9cd4d67a35af --> <!-- LOCATIONS START pkg/telemetrylogs/statement_builder.go#L262-L263 pkg/telemetrylogs/statement_builder.go#L385-L390 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`pkg/telemetrylogs/statement_builder.go#L385-L390`](https://github.com/drape-io/crbench-cursor-2026-09/blob/fc3477bdd83f48ff2dd18541e8d4983c6e824d78/pkg/telemetrylogs/statement_builder.go#L385-L390) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjM2ZTUxZTVjLWVkNzctNDBkYS1iNTkyLTAxM2IyY2RkOTYwMyIsImVuY3J5cHRpb25LZXkiOiJ3ZkVleFF5V1JVZk1HRVU3V1RIVUtvVE5sMVUxOVBpcUZWQVFGTE11SHRFIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjM2ZTUxZTVjLWVkNzctNDBkYS1iNTkyLTAxM2IyY2RkOTYwMyIsImVuY3J5cHRpb25LZXkiOiJ3ZkVleFF5V1JVZk1HRVU3V1RIVUtvVE5sMVUxOVBpcUZWQVFGTE11SHRFIiwiYnJhbmNoIjoidDItc2lnbm96LTgzMjgiLCJyZXBvT3duZXIiOiJkcmFwZS1pbyIsInJlcG9OYW1lIjoiY3JiZW5jaC1jdXJzb3ItMjAyNi0wOSIsInByTnVtYmVyIjo4MCwiY29tbWl0U2hhIjoiZmMzNDc3YmRkODNmNDhmZjJkZDE4NTQxZThkNDk4M2M2ZTgyNGQ3OCIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fc3477bdd83f48ff2dd18541e8d4983c6e824d78. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PR-level
<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes using high effort and found 4 potential issues. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTplMDljMzNkYi1jOWJiLTQ5Y2EtOTQ4My0wYjJjZmRkZTJmZWEiLCJlbmNyeXB0aW9uS2V5IjoidFdvZEVhUTJZRTJXUVNRMXJkX0QwNjVvWlRncHdFT0lLa0ppVjlGd1FWMCIsImJyYW5jaCI6InQyLXNpZ25vei04MzI4IiwicmVwb093bmVyIjoiZHJhcGUtaW8iLCJyZXBvTmFtZSI6ImNyYmVuY2gtY3Vyc29yLTIwMjYtMDkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fc3477bdd83f48ff2dd18541e8d4983c6e824d78. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ off by one
d5 medium ✗ —
d6 medium ✓ off by one
d7 medium ✗ —
d8 medium ✓ off by one
d9 high ✓ exact
valid · matches d3 · impact high
valid · matches d9 · impact high
valid · matches d2 · impact high
valid · matches d4 · impact high
valid · impact medium
The new comparison-path variable substitution has no `__all__` DynamicVariableType check, so `= $var` with ALL becomes `= '__all__'`. Only the IN path has that check. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · impact medium
processScalarFormula returns ScalarData, and applySeriesLimit returns early for anything that is not TimeSeriesData. The new limit call for scalar formulas therefore does nothing. [grounded: tree pkg/querier/postprocess.go] [consensus 3/3: valid=3]
valid · impact low
The new static-key addition matches only on name substring. It ignores the exact match type, field context, data type and limit, so unrelated intrinsic keys get added. [grounded: tree pkg/telemetrymetadata/metadata.go] [consensus 3/3: valid=3]
valid · matches d6 · impact medium
valid · impact high
The filter visitor now resolves variables, but the builder fingerprint never includes q.variables. Runs with different variable values share a cache key. [grounded: tree pkg/querier/builder_query.go] [consensus 3/3: valid=3]
valid · impact high
Every string value is looked up as a variable, and the fallback strips any first character. Literals such as 'xenv' therefore resolve to variable env (and an empty string would panic). [grounded: diff-section pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · matches d8 · impact medium
valid · impact low
Column headers come from formulaSeries[0].Labels, while each row is filled by label position. Label sets come from different series metadata (findUniqueLabelSets) whose label order and count can differ, so values can land under the wrong column. [grounded: diff-section pkg/querier/postprocess.go] [consensus 3/4: valid=3, uncertain=1]
valid · impact medium
Scalar column names are the SQL column names `__result_N` (readAsScalar uses colNames). A bucket alias taken from them never matches a user alias, so A.alias references fail. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
This is an incomplete change: traces added skipHaving for the limit CTE, but logs' buildScalarQuery still applies HAVING to whole-range totals inside __limit_cte. [grounded: tree pkg/telemetrylogs/statement_builder.go] [consensus 3/3: valid=3]
valid · impact low
Fingerprint now renders the reserved time variables from the request window. Queries that use them get a different cache key on every request, which defeats the cache. [grounded: tree pkg/querier/promql_query.go] [consensus 3/3: valid=3]
valid · impact medium
Removing timestamp from trace IntrinsicFields means ConditionFor now adds the exists filter. For the DateTime64 column that filter compares timestamp to '', which is invalid. [grounded: tree pkg/telemetrytraces/condition_builder.go] [consensus 3/3: valid=3]
raw comments (16)
pkg/querier/clickhouse_query.go:66
**ClickHouse dashboard variables always render empty** `formatValueForCH` gets the whole `VariableItem` struct rather than its value. It falls through to the default case and returns "", so `$var`, `{{var}}` and `[[var]]` all become empty text in the SQL. Pass `v.Value` to `formatValueForCH`. ``` pkg/querier/clickhouse_query.go:64 varsData := map[string]any{} pkg/querier/clickhouse_query.go:65 for k, v := range vars { pkg/querier/clickhouse_query.go:66 varsData[k] = formatValueForCH(v) pkg/querier/clickhouse_query.go:67 } pkg/types/querybuildertypes/querybuildertypesv5/req.go:189 type VariableItem struct { pkg/types/querybuildertypes/querybuildertypesv5/req.go:190 Type VariableType `json:"type"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:191 Value any `json:"value"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:192 } pkg/querier/format.go:50 default: pkg/querier/format.go:51 return "" ```
pkg/querier/promql_query.go:66
**PromQL dashboard variables always render empty** `formatValueForProm` gets the `VariableItem` struct rather than `v.Value`, so it hits the default case and returns "" for every variable. Pass `v.Value` to `formatValueForProm`. ``` pkg/querier/promql_query.go:63 func (q *promqlQuery) renderVars(query string, vars map[string]qbv5.VariableItem, start, end uint64) (string, error) { pkg/querier/promql_query.go:64 varsData := map[string]any{} pkg/querier/promql_query.go:65 for k, v := range vars { pkg/querier/promql_query.go:66 varsData[k] = formatValueForProm(v) pkg/types/querybuildertypes/querybuildertypesv5/req.go:189 type VariableItem struct { pkg/types/querybuildertypes/querybuildertypesv5/req.go:190 Type VariableType `json:"type"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:191 Value any `json:"value"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:192 } pkg/querier/format.go:177 } pkg/querier/format.go:178 default: ```
pkg/querybuilder/where_clause_visitor.go:347
**`IN ('')` filter panics the query** When the single IN value is an empty string and isn't a variable name, `var_[1:]` slices an empty string, which panics. Only strip a leading `$`, e.g. `strings.HasPrefix(var_, "$")` before `var_[1:]`. The same mistake is at `pkg/querybuilder/where_clause_visitor.go:427`. ``` pkg/querybuilder/where_clause_visitor.go:339 if len(values) == 1 { pkg/querybuilder/where_clause_visitor.go:340 if var_, ok := values[0].(string); ok { pkg/querybuilder/where_clause_visitor.go:341 // check if this is a variables pkg/querybuilder/where_clause_visitor.go:342 var ok bool pkg/querybuilder/where_clause_visitor.go:637 func (v *filterExpressionVisitor) VisitValue(ctx *grammar.ValueContext) any { pkg/querybuilder/where_clause_visitor.go:638 if ctx.QUOTED_TEXT() != nil { pkg/querybuilder/where_clause_visitor.go:639 txt := ctx.QUOTED_TEXT().GetText() pkg/querybuilder/where_clause_visitor.go:640 // trim quotes and return the value pkg/querybuilder/where_clause_visitor.go:641 return trimQuotes(txt) ```
pkg/querybuilder/where_clause_visitor.go:433
**Empty multi-select variable panics the query** When a variable's value is an empty list, `varValues[0]` indexes past the end and panics. Check `len(varValues) > 0` before indexing. ``` pkg/querybuilder/where_clause_visitor.go:430 if ok { pkg/querybuilder/where_clause_visitor.go:431 switch varValues := varItem.Value.(type) { pkg/querybuilder/where_clause_visitor.go:432 case []any: pkg/querybuilder/where_clause_visitor.go:433 value = varValues[0] pkg/types/querybuildertypes/querybuildertypesv5/req.go:189 type VariableItem struct { pkg/types/querybuildertypes/querybuildertypesv5/req.go:190 Type VariableType `json:"type"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:191 Value any `json:"value"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:192 } ```
pkg/querybuilder/where_clause_visitor.go:431
**`= $var` with ALL selected matches nothing** Only the IN path checks for the dynamic `__all__` value. A comparison like `service.name = $svc` uses `__all__` as a literal value instead of dropping the filter. Return "" for the `__all__` dynamic case here too. ``` pkg/querybuilder/where_clause_visitor.go:420 if var_, ok := value.(string); ok { pkg/querybuilder/where_clause_visitor.go:421 // check if this is a variables pkg/querybuilder/where_clause_visitor.go:422 var ok bool pkg/querybuilder/where_clause_visitor.go:423 var varItem qbtypes.VariableItem pkg/querybuilder/where_clause_visitor.go:350 if ok { pkg/querybuilder/where_clause_visitor.go:351 // we have a variable, now check for dynamic variable pkg/querybuilder/where_clause_visitor.go:352 if varItem.Type == qbtypes.DynamicVariableType { pkg/querybuilder/where_clause_visitor.go:353 // check if it is special value to skip entire filter, if so skip it pkg/querybuilder/where_clause_visitor.go:354 if all_, ok := varItem.Value.(string); ok && all_ == "__all__" { pkg/querybuilder/where_clause_visitor.go:355 return "" ```
pkg/querier/postprocess.go:237
**Scalar formula limit and order ignored** `processScalarFormula` returns `ScalarData`, but `applySeriesLimit` only handles `TimeSeriesData` and returns anything else unchanged. Scalar formulas therefore ignore `formula.Limit` and `formula.Order`. Apply the limit and order before converting the series to scalar, or support ScalarData in applySeriesLimit. ``` pkg/querier/postprocess.go:234 } else if req.RequestType == qbtypes.RequestTypeScalar { pkg/querier/postprocess.go:235 result := q.processScalarFormula(ctx, results, formula, req) pkg/querier/postprocess.go:236 if result != nil { pkg/querier/postprocess.go:237 result = q.applySeriesLimit(result, formula.Limit, formula.Order) pkg/querier/postprocess.go:178 func (q *querier) applySeriesLimit(result *qbtypes.Result, limit int, orderBy []qbtypes.OrderBy) *qbtypes.Result { pkg/querier/postprocess.go:179 tsData, ok := result.Value.(*qbtypes.TimeSeriesData) pkg/querier/postprocess.go:180 if !ok { pkg/querier/postprocess.go:181 return result pkg/querier/postprocess.go:182 } pkg/types/querybuildertypes/querybuildertypesv5/formula.go:208 for _, labelSet := range uniqueLabelSets { ```
pkg/telemetrymetadata/metadata.go:217
**Intrinsic trace keys returned for unrelated searches** The static intrinsic and calculated keys are matched only by substring on the name. The selector's field context, data type and exact match type are ignored, and the limit is skipped. Apply the selector's match type, field context and data type when adding static keys. The same mistake is at `pkg/telemetrymetadata/metadata.go:370`. ``` pkg/telemetrymetadata/metadata.go:217 staticKeys := []string{"isRoot", "isEntrypoint"} pkg/telemetrymetadata/metadata.go:218 staticKeys = append(staticKeys, telemetrytraces.IntrinsicFields...) pkg/telemetrymetadata/metadata.go:219 staticKeys = append(staticKeys, telemetrytraces.CalculatedFields...) pkg/telemetrymetadata/metadata.go:221 // add matching intrinsic and matching calculated fields pkg/telemetrymetadata/metadata.go:148 if fieldKeySelector.SelectorMatchType == telemetrytypes.FieldSelectorMatchTypeExact { pkg/telemetrymetadata/metadata.go:149 fieldKeyConds = append(fieldKeyConds, sb.E("tag_key", fieldKeySelector.Name)) pkg/telemetrymetadata/metadata.go:150 } else { pkg/telemetrymetadata/metadata.go:151 fieldKeyConds = append(fieldKeyConds, sb.Like("tag_key", "%"+fieldKeySelector.Name+"%")) pkg/telemetrymetadata/metadata.go:152 } pkg/telemetrymetadata/metadata.go:154 searchTexts = append(searchTexts, fieldKeySelector.Name) ```
pkg/querier/clickhouse_query.go:86
**Variable text is re-run as a Go template** Values are substituted into the query before it is parsed as a Go template. A value containing `{{` breaks parsing, and a template action inside a value gets executed. Run the template on the original query first, then do the literal substitutions. ``` pkg/querier/clickhouse_query.go:79 for _, k := range keys { pkg/querier/clickhouse_query.go:80 query = strings.Replace(query, fmt.Sprintf("{{%s}}", k), fmt.Sprint(varsData[k]), -1) pkg/querier/clickhouse_query.go:81 query = strings.Replace(query, fmt.Sprintf("[[%s]]", k), fmt.Sprint(varsData[k]), -1) pkg/querier/clickhouse_query.go:82 query = strings.Replace(query, fmt.Sprintf("$%s", k), fmt.Sprint(varsData[k]), -1) pkg/querier/format.go:24 return fmt.Sprintf("'%s'", quoteEscapedString(x)) ```
pkg/querier/querier.go:214
**Cache serves results for previous variable values** Builder filters now resolve `$var` from `tmplVars`, but `builderQuery.Fingerprint` only includes the raw filter text. A time-series query run with a different variable value gets the same cache key. Add the resolved variables, or the rendered filter, to the builder query fingerprint. ``` pkg/querier/querier.go:208 bq := newBuilderQuery(q.telemetryStore, q.traceStmtBuilder, spec, timeRange, req.RequestType, tmplVars) pkg/querier/querier.go:209 queries[spec.Name] = bq pkg/querier/querier.go:210 steps[spec.Name] = spec.StepInterval pkg/querier/querier.go:211 case qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]: pkg/querier/builder_query.go:49 func (q *builderQuery[T]) Fingerprint() string { pkg/querier/builder_query.go:51 if (q.spec.Signal == telemetrytypes.SignalTraces || pkg/querier/builder_query.go:52 q.spec.Signal == telemetrytypes.SignalLogs) && q.kind != qbtypes.RequestTypeTimeSeries { pkg/querier/builder_query.go:53 // No caching for non-timeseries queries pkg/querier/builder_query.go:54 return "" pkg/querier/builder_query.go:55 } ```
pkg/querybuilder/where_clause_visitor.go:424
**Plain filter literals get replaced by variable values** Every string value is looked up as a variable, even without `$`, and the fallback drops whatever the first character is. So `= 'env'` or `= 'xenv'` gets the value of variable `env`. Only resolve values that start with `$`. ``` pkg/querybuilder/where_clause_visitor.go:420 if var_, ok := value.(string); ok { pkg/querybuilder/where_clause_visitor.go:421 // check if this is a variables pkg/querybuilder/where_clause_visitor.go:422 var ok bool pkg/querybuilder/where_clause_visitor.go:423 var varItem qbtypes.VariableItem pkg/querybuilder/where_clause_visitor.go:424 varItem, ok = v.variables[var_] pkg/querybuilder/where_clause_visitor.go:425 // if not present, try without `$` prefix pkg/querybuilder/where_clause_visitor.go:426 if !ok { pkg/querybuilder/where_clause_visitor.go:427 varItem, ok = v.variables[var_[1:]] pkg/querybuilder/where_clause_visitor.go:428 } ```
pkg/querybuilder/having_rewriter.go:110
**Having can't reference aggregations containing quotes** Quoted strings are swapped for placeholders before aggregation expressions are matched. An expression like `countIf(level='error')` written in the having text no longer matches its map entry and is left unrewritten. Match aggregation expressions before masking quoted strings. ``` pkg/querybuilder/having_rewriter.go:107 quotedStrings := make(map[string]string) pkg/querybuilder/having_rewriter.go:108 quotePattern := regexp.MustCompile(`'[^']*'|"[^"]*"`) pkg/querybuilder/having_rewriter.go:109 quotedIdx := 0 pkg/querybuilder/having_rewriter.go:111 expression = quotePattern.ReplaceAllStringFunc(expression, func(match string) string { pkg/querybuilder/having_rewriter.go:58 r.columnMap = make(map[string]string) pkg/querybuilder/having_rewriter.go:60 for idx, agg := range aggregations { pkg/querybuilder/having_rewriter.go:61 sqlColumn := fmt.Sprintf("__result_%d", idx) pkg/querybuilder/having_rewriter.go:63 if agg.Alias != "" { pkg/querybuilder/having_rewriter.go:64 r.columnMap[agg.Alias] = sqlColumn pkg/querybuilder/having_rewriter.go:65 } ```
pkg/querier/postprocess.go:457
**Formula row labels placed under wrong columns** When the formula's queries group by the same keys in different orders, rows are filled by label position while column headers come from the first result series, so values can land under the wrong group column. Place each label by matching its key to the column instead. ``` pkg/querier/postprocess.go:435 if len(formulaSeries) > 0 && len(formulaSeries[0].Labels) > 0 { pkg/querier/postprocess.go:436 for _, label := range formulaSeries[0].Labels { pkg/querier/postprocess.go:437 scalarResult.Columns = append(scalarResult.Columns, &qbtypes.ColumnDescriptor{ pkg/querier/postprocess.go:438 TelemetryFieldKey: label.Key, pkg/types/querybuildertypes/querybuildertypesv5/formula.go:193 func (fe *FormulaEvaluator) EvaluateFormula(timeSeriesData map[string]*TimeSeriesData) ([]*TimeSeries, error) { pkg/types/querybuildertypes/querybuildertypesv5/formula.go:194 // Build lookup structures for all referenced aggregations pkg/types/querybuildertypes/querybuildertypesv5/formula.go:195 lookup := fe.buildSeriesLookup(timeSeriesData) pkg/types/querybuildertypes/querybuildertypesv5/formula.go:197 // Find all unique label combinations across referenced series pkg/types/querybuildertypes/querybuildertypesv5/formula.go:198 uniqueLabelSets := fe.findUniqueLabelSets(lookup) pkg/types/querybuildertypes/querybuildertypesv5/formula.go:200 // Process each unique label set ```
pkg/querier/postprocess.go:393
**Alias references fail in scalar formulas** The bucket alias is set from the scalar column name, which is always `__result_N`, so formulas like `A.total / B.total` never match a bucket. Set the alias from the query's aggregation alias (`spec.Aggregations[idx].Alias`). ``` pkg/querier/postprocess.go:388 Alias: scalarData.Columns[colIdx].Name, pkg/querier/postprocess.go:389 Meta: scalarData.Columns[colIdx].Meta, pkg/querier/postprocess.go:390 Series: make([]*qbtypes.TimeSeries, 0), pkg/querier/postprocess.go:391 } pkg/querier/consume.go:277 for i, name := range colNames { pkg/querier/consume.go:278 colType := qbtypes.ColumnTypeGroup pkg/querier/consume.go:279 if aggRe.MatchString(name) { pkg/querier/consume.go:280 colType = qbtypes.ColumnTypeAggregation pkg/querier/consume.go:281 } pkg/querier/consume.go:282 cd[i] = &qbtypes.ColumnDescriptor{ ```
pkg/telemetrylogs/statement_builder.go:386
**Logs top-N CTE applies HAVING to totals** Traces now skip HAVING inside the limit CTE, but logs still apply the rewritten HAVING in `buildScalarQuery` when building `__limit_cte`. Groups are dropped based on their whole-range aggregate before the per-bucket HAVING runs. Add a skipHaving flag to logs `buildScalarQuery`, as traces does, and pass true for the limit CTE. ``` pkg/telemetrylogs/statement_builder.go:386 if query.Having != nil && query.Having.Expression != "" { pkg/telemetrylogs/statement_builder.go:387 rewriter := querybuilder.NewHavingExpressionRewriter() pkg/telemetrylogs/statement_builder.go:388 rewrittenExpr := rewriter.RewriteForLogs(query.Having.Expression, query.Aggregations) pkg/telemetrylogs/statement_builder.go:389 sb.Having(rewrittenExpr) pkg/telemetrytraces/statement_builder.go:303 cteStmt, err := b.buildScalarQuery(ctx, cteSB, query, start, end, keys, variables, true, true) pkg/telemetrytraces/statement_builder.go:423 if query.Having != nil && query.Having.Expression != "" && !skipHaving { pkg/telemetrytraces/statement_builder.go:424 rewriter := querybuilder.NewHavingExpressionRewriter() pkg/telemetrytraces/statement_builder.go:425 rewrittenExpr := rewriter.RewriteForTraces(query.Having.Expression, query.Aggregations) pkg/telemetrytraces/statement_builder.go:426 sb.Having(rewrittenExpr) pkg/telemetrytraces/statement_builder.go:427 } ```
pkg/querier/promql_query.go:44
**PromQL cache misses whenever time vars used** `Fingerprint` renders the reserved time variables using the request window. Any PromQL that references `$start_timestamp` etc. gets a new cache key on every request. Fingerprint the raw query plus user variable values, not the time-rendered query. ``` pkg/querier/promql_query.go:43 func (q *promqlQuery) Fingerprint() string { pkg/querier/promql_query.go:44 query, err := q.renderVars(q.query.Query, q.vars, q.tr.From, q.tr.To) pkg/querier/promql_query.go:45 if err != nil { pkg/querier/promql_query.go:46 q.logger.ErrorContext(context.TODO(), "failed render template variables", "query", q.query.Query) pkg/querybuilder/time.go:90 func AssignReservedVars(vars map[string]any, start, end uint64) { pkg/querybuilder/time.go:91 start = ToNanoSecs(start) pkg/querybuilder/time.go:92 end = ToNanoSecs(end) pkg/querybuilder/time.go:94 vars["start_timestamp"] = start / 1_000_000_000 pkg/querybuilder/time.go:95 vars["end_timestamp"] = end / 1_000_000_000 pkg/querybuilder/time.go:96 vars["start_timestamp_ms"] = start / 1_000_000 ```
pkg/telemetrytraces/const.go:4
**Trace timestamp filters get invalid exists check** With `timestamp` dropped from `IntrinsicFields`, `ConditionFor` now appends the default exists check for it. For the DateTime64 column that check compares against an empty string. Keep `timestamp` among the fields that skip the exists check, or give DateTime64 a proper exists condition. ``` pkg/telemetrytraces/const.go:5 (base) "timestamp", pkg/telemetrytraces/field_mapper.go:21 "timestamp": {Name: "timestamp", Type: schema.DateTime64ColumnType{Precision: 9, Timezone: "UTC"}}, pkg/telemetrytraces/condition_builder.go:144 schema.DateTime64ColumnType{Precision: 9, Timezone: "UTC"}: pkg/telemetrytraces/condition_builder.go:145 value = "" pkg/telemetrytraces/condition_builder.go:146 if operator == qbtypes.FilterOperatorExists { pkg/telemetrytraces/condition_builder.go:147 return sb.NE(tblFieldName, value), nil ```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ off by one
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✗ —
d9 high ✓ exact
valid · matches d3 · impact high
valid · matches d9 · impact high
valid · matches d2 · impact high
valid · impact medium
The fallback strips the first character of any string without checking that it is a dollar sign, so a literal value can resolve to an unrelated variable. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · impact medium
The scalar-comparison variable branch replaces the value but never checks for __all__. An equality filter on a dynamic __all__ variable therefore compares against the literal '__all__' instead of being skipped. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · matches d4 · impact high
valid · impact low
Static keys are added by substring match on the name alone, ignoring exact match type, field context and data type, so spurious keys get added (e.g. parent_span_id for an exact span_id selector). [grounded: tree pkg/telemetrymetadata/metadata.go] [consensus 3/3: valid=3]
valid · impact low
Traces gained skipHaving for the limit CTE but the parallel logs builder still applies HAVING there. This is an incomplete parallel change that makes logs and traces behave differently. [grounded: tree pkg/telemetrylogs/statement_builder.go] [consensus 3/3: valid=3]
valid · impact medium
With timestamp removed from IntrinsicFields, operators such as >= or = on traces timestamp now get an exists filter appended. The field mapper types the column as DateTime64, so that filter is timestamp != '' on a DateTime64 column. [grounded: tree pkg/telemetrytraces/condition_builder.go] [consensus 3/3: valid=3]
valid · impact medium
The new __all__ path returns an empty string, which VisitUnaryExpression wraps as NOT () and parenthesized primaries wrap as (), producing invalid SQL. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
raw comments (10)
pkg/querier/clickhouse_query.go:66
**Query variables render as empty strings** `renderVars` passes the whole `VariableItem` struct to `formatValueForCH`, which only handles raw values and returns "" for anything else. Every user variable ends up substituted as an empty string. Format `v.Value` instead of `v`. ``` pkg/querier/clickhouse_query.go:63 func (q *chSQLQuery) renderVars(query string, vars map[string]qbtypes.VariableItem, start, end uint64) (string, error) { pkg/querier/clickhouse_query.go:64 varsData := map[string]any{} pkg/querier/clickhouse_query.go:65 for k, v := range vars { pkg/querier/clickhouse_query.go:66 varsData[k] = formatValueForCH(v) pkg/types/querybuildertypes/querybuildertypesv5/req.go:189 type VariableItem struct { pkg/types/querybuildertypes/querybuildertypesv5/req.go:190 Type VariableType `json:"type"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:191 Value any `json:"value"` pkg/types/querybuildertypes/querybuildertypesv5/req.go:192 } ```
pkg/querier/promql_query.go:65
**PromQL variables render as empty strings** `renderVars` passes the whole `VariableItem` struct to `formatValueForProm`, whose switch has no struct case and returns "". Variables are all substituted as empty. Format `v.Value`. ``` pkg/querier/promql_query.go:64 varsData := map[string]any{} pkg/querier/promql_query.go:65 for k, v := range vars { pkg/querier/promql_query.go:66 varsData[k] = formatValueForProm(v) pkg/querier/promql_query.go:67 } ```
pkg/querybuilder/where_clause_visitor.go:338
**Panic on empty-string filter values** The variable lookup does `var_[1:]` without checking the string is non-empty or starts with `$`. An empty string literal makes the slice go out of range, and the same code is repeated in the single-value comparison branch. Only strip the prefix when `strings.HasPrefix(var_, "$")`, and handle empty strings. ``` pkg/querybuilder/where_clause_visitor.go:337 } pkg/querybuilder/where_clause_visitor.go:339 if len(values) == 1 { pkg/querybuilder/where_clause_visitor.go:340 if var_, ok := values[0].(string); ok { pkg/querybuilder/where_clause_visitor.go:341 // check if this is a variables ```
pkg/querybuilder/where_clause_visitor.go:343
**Literal values wrongly replaced by variables** When the exact name is not a variable, the code drops the first character of every string value and looks that up, without checking the character is `$`. A plain value like 'ahost' matches a variable named `host`. Strip only a leading `$`. ``` pkg/querybuilder/where_clause_visitor.go:341 // check if this is a variables pkg/querybuilder/where_clause_visitor.go:342 var ok bool pkg/querybuilder/where_clause_visitor.go:343 var varItem qbtypes.VariableItem pkg/querybuilder/where_clause_visitor.go:344 varItem, ok = v.variables[var_] ```
pkg/querybuilder/where_clause_visitor.go:420
**"All values" variable not honored for equality filters** The dynamic-variable `__all__` skip is applied only in the IN/NOT IN path. The `=`/`!=`/`LIKE` path resolves the variable value but never checks for `__all__`. Apply the same `__all__` check in the scalar-comparison variable branch. ``` pkg/querybuilder/where_clause_visitor.go:417 if len(values) > 0 { pkg/querybuilder/where_clause_visitor.go:418 value := v.Visit(values[0]) pkg/querybuilder/where_clause_visitor.go:420 if var_, ok := value.(string); ok { pkg/querybuilder/where_clause_visitor.go:421 // check if this is a variables ```
pkg/querybuilder/where_clause_visitor.go:433
**Empty list variable panics in filter** When a variable's value is an empty `[]any`, `varValues[0]` is indexed without a length check in the single-value comparison path. Handle the empty-list case, e.g. return an empty condition or an error. ``` pkg/querybuilder/where_clause_visitor.go:430 if ok { pkg/querybuilder/where_clause_visitor.go:431 switch varValues := varItem.Value.(type) { pkg/querybuilder/where_clause_visitor.go:432 case []any: pkg/querybuilder/where_clause_visitor.go:433 value = varValues[0] ```
pkg/telemetrymetadata/metadata.go:217
**Static keys ignore selector filters** Intrinsic and calculated keys are appended whenever their name contains any selector's name. This ignores exact match, field context, data type and limit. Apply the selector's match type, context, data type and limit when adding static keys. ``` pkg/telemetrymetadata/metadata.go:154 searchTexts = append(searchTexts, fieldKeySelector.Name) pkg/telemetrymetadata/metadata.go:217 staticKeys := []string{"isRoot", "isEntrypoint"} pkg/telemetrymetadata/metadata.go:218 staticKeys = append(staticKeys, telemetrytraces.IntrinsicFields...) pkg/telemetrymetadata/metadata.go:219 staticKeys = append(staticKeys, telemetrytraces.CalculatedFields...) ```
pkg/telemetrylogs/statement_builder.go:387
**Logs top-N CTE applies HAVING, traces doesn't** The traces builder was changed to skip HAVING in the `__limit_cte` (new `skipHaving` argument). The logs builder does the same job but still applies the rewritten HAVING there. Add a `skipHaving` parameter to the logs `buildScalarQuery` and pass true for the limit CTE, as traces does. ``` pkg/telemetrylogs/statement_builder.go:385 // Add having clause if needed pkg/telemetrylogs/statement_builder.go:386 if query.Having != nil && query.Having.Expression != "" { pkg/telemetrylogs/statement_builder.go:387 rewriter := querybuilder.NewHavingExpressionRewriter() pkg/telemetrylogs/statement_builder.go:388 rewrittenExpr := rewriter.RewriteForLogs(query.Having.Expression, query.Aggregations) ```
pkg/telemetrytraces/const.go:4
**Removing timestamp adds a bogus exists filter** `timestamp` was dropped from `IntrinsicFields`, which `ConditionFor` uses to skip the default exists filter. Comparisons on `timestamp` now get an exists condition appended, which is `timestamp != ''` on a DateTime64 column for traces. Keep `timestamp` in the fields that skip the exists filter. ``` pkg/telemetrytraces/const.go:4 IntrinsicFields = []string{ pkg/telemetrytraces/const.go:5 "trace_id", pkg/telemetrylogs/const.go:13 IntrinsicFields = []string{ pkg/telemetrylogs/const.go:14 "body", "trace_id", "span_id", "trace_flags", "severity_text", "severity_number", "scope_name", "scope_version", pkg/telemetrytraces/condition_builder_test.go:27 name: "Not Equal operator - timestamp", pkg/telemetrytraces/condition_builder_test.go:28 key: telemetrytypes.TelemetryFieldKey{ pkg/telemetrytraces/condition_builder_test.go:29 Name: "timestamp", pkg/telemetrytraces/condition_builder_test.go:30 FieldContext: telemetrytypes.FieldContextSpan, pkg/telemetrytraces/condition_builder_test.go:31 }, pkg/telemetrytraces/condition_builder_test.go:32 operator: qbtypes.FilterOperatorNotEqual, ```
pkg/querybuilder/where_clause_visitor.go:349
**`__all__` variable yields invalid SQL when wrapped** For a dynamic variable set to `__all__`, `VisitComparison` returns an empty string. `VisitUnaryExpression` and parenthesized `VisitPrimary` then wrap it as `NOT ()` or `()`, which is invalid SQL. Return a sentinel such as `true`, or have the callers drop empty conditions before wrapping. ``` pkg/querybuilder/where_clause_visitor.go:345 // if not present, try without `$` prefix pkg/querybuilder/where_clause_visitor.go:346 if !ok { pkg/querybuilder/where_clause_visitor.go:347 varItem, ok = v.variables[var_[1:]] pkg/querybuilder/where_clause_visitor.go:348 } ```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✗ —
d4 high ✓ exact
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✗ —
d9 high ✗ —
valid · matches d2 · impact high
invalid
The only caller passes the whole VariableItem struct, not its Value, so the switch always falls to default and returns "". The []any branch with the unchecked string assertion is never reached from variables, so the claimed panic or corrupted SQL does not occur on this path. [invalid: contradiction] [consensus 3/3: invalid=3]
valid · impact low
Columns are derived only from the first series, and each row's label values are filled by position. Series with different label keys or ordering get mislabeled or truncated. [grounded: tree pkg/querier/postprocess.go] [consensus 3/3: valid=3]
valid · impact medium
After placeholder substitution, the whole query is parsed with text/template. Any leftover literal {{name}} is parsed as an undefined function call and fails, so the query errors out before execution. The same code exists in promql_query.go. [grounded: tree pkg/querier/clickhouse_query.go] [consensus 3/3: valid=3]
raw comments (5)
pkg/querybuilder/where_clause_visitor.go:347
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Empty Filters Panic** A valid empty-string filter such as `service.name = ''` or `service.name IN ('')` reaches the variable fallback with an empty string. Slicing `var_[1:]` then panics, so the request returns an internal error instead of evaluating the filter. The related scalar expansion also indexes `varValues[0]` without checking its length, causing the same failure when a variable contains an empty array.
pkg/querier/format.go:40
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Mixed Arrays Break Formatting** `VariableItem.Value` accepts arbitrary JSON arrays, but this formatter assumes every element has the first element's type. A value such as `["api", 1]` reaches the unchecked `sVal.(string)` assertion and panics. For numeric-first arrays, later strings or objects are instead emitted as unquoted SQL tokens, which can corrupt the ClickHouse query before execution. Each element needs validation or formatting according to its own type.
pkg/querier/postprocess.go:457
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Scalar Labels Become Corrupted** The scalar result derives all group columns from `formulaSeries[0]`, then copies every other series' labels by position. Formula evaluation can return distinct label sets in nondeterministic completion order, so a later series with different keys, ordering, or extra labels is mislabeled or truncated in the response. Build a stable schema by label key and populate each row using those keys.
pkg/querier/clickhouse_query.go:95
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **Template Pass Rejects Queries** After supported placeholders are replaced, the complete query is still parsed as a Go template. Valid literal text such as ClickHouse `SELECT '{{dashboard}}'` or PromQL `label_replace(up, "display", "{{cluster}}", "job", ".*")` is therefore treated as an undefined template action and rejected before reaching the backend. Avoid the unrestricted second template pass or preserve doubled braces that are not recognized variables. The same issue exists in `pkg/querier/promql_query.go:85-95`.
PR-level
<h3>Greptile Summary</h3> This PR expands v5 query execution and query-builder behavior across template variables, scalar formulas, HAVING expressions, field discovery, and parser syntax. - Adds variable rendering for raw ClickHouse and PromQL queries and variable expansion in builder filters. - Adds scalar formula post-processing, formula limits, and automatic fill-zero arguments. - Rewrites HAVING references to generated aggregation columns for logs, traces, and metrics. - Extends filter grammar for unwrapped `IN` variables and `$`-prefixed identifiers. - Adjusts field-search parameters and static telemetry field metadata. <h3>Confidence Score: 1/5</h3> The PR is not safe to merge because valid filter inputs can panic, heterogeneous variables can crash or corrupt raw queries, scalar formulas can return mislabeled data, and valid raw queries containing doubled-brace literals are rejected. Four independent blocking failures remain in newly added variable expansion, variable formatting, scalar formula conversion, and raw-query rendering. **Files Needing Attention:** pkg/querybuilder/where_clause_visitor.go, pkg/querier/format.go, pkg/querier/postprocess.go, pkg/querier/clickhouse_query.go, pkg/querier/promql_query.go <details><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | pkg/querybuilder/where_clause_visitor.go | Adds filter-variable expansion but introduces panics for empty string literals and empty array variables. | | pkg/querier/format.go | Adds query-language value formatting but unsafely assumes homogeneous arbitrary JSON arrays. | | pkg/querier/clickhouse_query.go | Adds ClickHouse template rendering, including an unrestricted second template pass that rejects valid literal query text. | | pkg/querier/promql_query.go | Adds PromQL template rendering and shares the doubled-brace literal regression with ClickHouse queries. | | pkg/querier/postprocess.go | Adds scalar formulas and fill-zero preparation, but scalar formula rows can corrupt nonuniform label sets. | | pkg/querybuilder/having_rewriter.go | Introduces aggregation-reference rewriting for HAVING expressions. | | pkg/apis/fields/parse.go | Migrates field search parameters to searchText while retaining name as the selected value field key. | | grammar/FilterQuery.g4 | Extends IN syntax and permits dollar-prefixed variable tokens. | </details> <details open><summary><h3>Flowchart</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart LR A[POST /api/v5/query_range] --> B[Decode and validate request] B --> C{Query type} C -->|Builder| D[Parse filters and expand variables] C -->|ClickHouse SQL| E[Render reserved and request variables] C -->|PromQL| F[Render reserved and request variables] D --> G[Build telemetry SQL] E --> H[ClickHouse] F --> I[Prometheus engine] G --> H H --> J[Query results] I --> J J --> K[Functions and formula evaluation] K --> L[Time-series or scalar response] ``` </details> <!-- greptile_other_comments_section --> <sub>Reviews (1): Last reviewed commit: ["Update ee/query-service/app/api/api.go a..."](https://github.com/drape-io/crbench-greptile-2026-09/commit/f96942b459a701c3c41306ed0b65bd71e627cc7e) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284856)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ off by one
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✓ off by one
d9 high ✓ exact
valid · matches d3 · impact high
valid · impact high
An empty quoted literal reaches here as an empty string. The first map lookup misses, so the code slices var_[1:] on an empty string, which panics. Because the first character is dropped without checking that it is '$', literals that match a variable name are also rewritten. This lookup was added by this change. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · impact high
After this change the filter visitor substitutes variable values into the SQL, but Fingerprint keys only on the raw filter text. Two requests with the same filter text and different variable values get the same cache key, so the cache can return results for the wrong selection. Before this change the variables did not affect the SQL, so this change is what makes the fingerprint wrong. [grounded: tree pkg/querier/builder_query.go] [consensus 3/3: valid=3]
valid · matches d8 · impact medium
valid · matches d9 · impact high
valid · matches d2 · impact high
valid · impact high
This is the same issue as finding 2: the fingerprint leaves out the variable values that now change the SQL, so cached results can be stale after a dashboard variable changes. [grounded: tree pkg/querier/builder_query.go] [consensus 3/3: valid=3]
valid · matches d4 · impact high
raw comments (8)
pkg/querier/clickhouse_query.go:192
[P1] Template variables render as empty strings in ClickHouse and PromQL queries `renderVars` calls `formatValueForCH(v)` on the whole `qbtypes.VariableItem` struct instead of `v.Value`. `formatValueForCH` (and `getPointerValue`) only handle primitives and slices, so a struct falls through to `default: return ""`. Every user variable in a ClickHouse SQL query therefore becomes an empty string: `WHERE service = {{.service}}` turns into `WHERE service = `, which is invalid SQL or matches the wrong rows. `promql_query.go:854-856` has the same problem with `formatValueForProm(v)`, so PromQL `$var` references are dropped as well. Only the reserved time variables work.
pkg/querybuilder/where_clause_visitor.go:1321
[P1] Variable lookup panics on empty string values and rewrites values that aren't variables Every string comparison value now goes through `v.variables[var_]` and, if that misses, `v.variables[var_[1:]]`, with no check for a `$` prefix. For an empty literal such as `service.name = ''` (or `x IN ('')`, the same code at 1288-1296), `var_[1:]` slices an empty string and panics with an out-of-range error, so a valid filter crashes the request. Because the first character is dropped no matter what it is, any literal is also replaced by a variable's value when it equals the variable name (`env = 'env'`) or equals it after losing its first character (`'xenv'` → variable `env`). That silently changes the user's filter. The lookup should only run for values that start with `$`.
pkg/querybuilder/where_clause_visitor.go:1287
[P1] Builder-query cache fingerprint ignores variable values that now change the SQL After this change, builder-query filters resolve `$var` from the request variables (e.g. `service.name IN $service`). `builderQuery.Fingerprint()` in `pkg/querier/builder_query.go` still uses only the raw filter expression and doesn't include `q.variables`. Two time-series requests (or any metrics request) with the same filter text but different dashboard variable values get the same fingerprint, so the bucket cache returns the first variable selection's results for later selections.
pkg/querybuilder/having_rewriter.go:1133
[P3] Having rewriter can't match aggregation expressions that contain quoted literals `rewriteExpression` swaps quoted strings for `__QUOTED_n__` placeholders before it applies the column map, but the map keys are the raw aggregation expressions, quotes included (e.g. `countIf(level='error')`). For a having clause like `countIf(level='error') › 10`, the expression becomes `countIf(level=__QUOTED_0__) › 10` before matching, never matches, and is sent to ClickHouse unchanged instead of being rewritten to `__result_N`. That only works if an alias is used.
pkg/querier/clickhouse_query.go:193
[P1] ClickHouse/PromQL templates receive the VariableItem struct instead of its value `renderVars` passes the whole `qbtypes.VariableItem` (a `{Type, Value}` struct) to `formatValueForCH`. None of the type-switch cases match a struct, so the default branch returns `""`. As a result, every dashboard variable in a ClickHouse SQL query (`{{var}}`, `[[var]]`, `$var`) is replaced with an empty string instead of the selected value, which breaks or silently changes the query. The PromQL path in `pkg/querier/promql_query.go:854-856` has the same bug: it calls `formatValueForProm(v)` with the struct, so every PromQL variable also renders as `""`. Only the reserved time variables are substituted correctly. Both call sites should pass `v.Value`.
pkg/querybuilder/where_clause_visitor.go:1325
[P1] Empty string filter values panic in the variable lookup The new lookup runs `v.variables[var_[1:]]` on every string value that isn't an exact variable key, without first checking `len(var_) › 0` or `strings.HasPrefix(var_, "$")`. A plain filter such as `body = ''` or `x IN ('')` hits `""[1:]` and panics with slice bounds out of range. The IN-clause branch at lines 1287-1296 has the same problem. Statement building can run inside the bounded-parallelism goroutines in `executeWithCache` (`querier.go:337`, via `createRangedQuery` → `Execute` → `Build`). The new `recover` in `QueryRange` doesn't cover those goroutines, so this can crash the whole process rather than return a 500. Because the code strips the first character unconditionally, any value whose tail happens to match a variable name (e.g. `'xenv'` with a variable `env`) is also silently replaced by that variable's value.
pkg/querier/querier.go:972
[P1] Builder query cache key ignores variable values now that filters substitute them The builder filter expression can now contain variable references (`service.name IN $service`) that are resolved from `req.Variables` at build time. `builderQuery.Fingerprint()` (`builder_query.go:88-91`) still keys only on the raw `Filter.Expression` text and does not include the variable values. Cached queries (metrics, and logs/traces time series) would therefore return results from the bucket cache that were computed for a previous variable selection when a user changes a dashboard variable. The variable values (or the rendered filter) need to be part of the fingerprint.
pkg/querybuilder/where_clause_visitor.go:1332
[P2] Comparison with an empty-list variable panics In the comparison path, when the variable's `Value` is a `[]any`, the code takes `varValues[0]` without checking the length. A dashboard variable with nothing selected (serialized as `[]`) used in a filter such as `service.name = $service` causes an index-out-of-range panic during statement building. As with the previous finding, this can happen inside the unrecovered cache goroutines.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ off by one
d5 medium ✗ —
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✗ —
d9 high ✓ exact
valid · matches d3 · impact high
valid · matches d9 · impact high
valid · impact high
On a lookup miss, the new code slices `var_[1:]` without checking for a `$` prefix. An empty quoted value such as `''` makes `var_` empty, and slicing it this way panics. A non-variable literal like 'ahost' also matches a variable named 'host'. In addition, `varValues[0]` panics when the variable holds an empty list. [grounded: diff] [consensus 3/3: valid=3]
valid · impact high
`v` is a `qbtypes.VariableItem` struct. Neither `formatValueForCH`/`getPointerValue` nor `formatValueForProm` handles that type, so both hit their default case and return an empty string. As a result, every user variable is replaced with an empty string. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d2 · impact high
valid · matches d4 · impact high
valid · impact medium
With `timestamp` removed from IntrinsicFields, `ConditionFor` no longer skips the default exists filter for it. For traces, the DateTime64 branch in `conditionFor` then produces `timestamp <> ''`, and logs get a redundant `<> 0`. The diff also deletes the timestamp condition tests in the logs test file. [grounded: tree pkg/telemetrytraces/condition_builder.go] [consensus 3/3: valid=3]
raw comments (7)
pkg/querier/clickhouse_query.go:65
[P1] Variables are formatted from the VariableItem struct, not its value In `renderVars`, `for k, v := range vars` iterates `map[string]qbtypes.VariableItem`, so `v` is the struct `{Type, Value}`. `formatValueForCH(v)` has no case for that struct and falls to `default: return ""`. Every user-defined dashboard variable in a ClickHouse SQL query (`{{var}}`, `[[var]]`, `$var`) is therefore replaced with an empty string. The query is then sent as invalid or wrong SQL, for example `WHERE service IN ()`. The fix is to format `v.Value`.
pkg/querier/promql_query.go:65
[P1] Same bug for PromQL variables `formatValueForProm(v)` is called with the `VariableItem` struct instead of `v.Value`. It hits `default: return ""`, so all PromQL dashboard variables render as empty strings. A query like `up{job=~"$job"}` becomes `up{job=~""}`. The fingerprint is built from the same broken render.
pkg/querybuilder/where_clause_visitor.go:425
[P1] Variable lookup panics on empty strings and strips the first character of ordinary strings Any string comparison value is looked up in `v.variables`. If the exact lookup misses, the code retries with `var_[1:]` without checking for a `$` prefix. For an empty value such as `service.name = ''`, `""[1:]` panics with a slice-bounds error. The same pattern appears at line 347 for `IN` with a single value. For non-variable values like `name = 'ahost'`, it wrongly matches a variable named `host` and substitutes that variable's value into the filter. The lookup should only strip the prefix when `strings.HasPrefix(var_, "$")`. Line 433, `varValues[0]`, also panics if the variable's value is an empty `[]any`.
pkg/querier/clickhouse_query.go:65
[P1] Query variables are rendered as empty strings in ClickHouse/PromQL queries (same at pkg/querier/promql_query.go:65-67) `renderVars` passes the whole `qbtypes.VariableItem` struct (`{Type, Value}`) to `formatValueForCH` / `formatValueForProm`. Neither function handles that type, so both hit `default: return ""`. Any `{{var}}`, `[[var]]` or `$var` in a raw ClickHouse SQL or PromQL query is replaced with an empty string, which gives invalid or wrong queries. Only the reserved vars (`start_timestamp` etc.) work. The call should pass `v.Value`.
pkg/querybuilder/where_clause_visitor.go:427
[P1] Panic on empty-string literal in filter expressions (also 347) When a value is not a known variable name, the code falls back to `v.variables[var_[1:]]`. For an empty string, `""[1:]` panics with "slice bounds out of range". Any filter like `service.name = ''` or `x IN ('')` crashes the query build, whether or not variables were supplied. The handler's new `recover` turns this into a 500. The same lookup also treats any literal as a variable by dropping its first character: `host = 'xfoo'` is substituted if a variable named `foo` exists. The fallback should apply only when the value actually starts with `$` and has length greater than 1.
pkg/querybuilder/where_clause_visitor.go:433
[P2] `varValues[0]` panics on an empty list variable In the non-IN comparison path, a variable whose `Value` is an empty `[]any` (for example a multi-select variable with nothing selected) is indexed with `[0]`, which panics.
pkg/telemetrytraces/const.go:4
[P2] Removing `timestamp` from IntrinsicFields makes timestamp filters add an exists check (and pkg/telemetrylogs/const.go:13-15) `timestamp` was treated as intrinsic, so `AddDefaultExistsFilter` skipped the exists condition for it. It is no longer in `IntrinsicFields` (and not in the Deprecated lists either), so `timestamp › X` and similar now get ANDed with an exists check. For traces the column is `DateTime64`, so the check becomes `timestamp ‹› ''`, comparing a DateTime64 to an empty string. For logs it adds a redundant `timestamp ‹› 0`. The tests that covered timestamp conditions in `pkg/telemetrylogs/condition_builder_test.go` were deleted rather than updated.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
DefectSeverityFoundGrade
d1 high ✗ —
d2 high ✓ exact
d3 high ✓ exact
d4 high ✓ exact
d5 medium ✓ off by one
d6 medium ✗ —
d7 medium ✗ —
d8 medium ✓ off by one
d9 high ✓ exact
valid · impact high
builderQuery.Fingerprint (builder_query.go:49-128) covers filter text, aggs, group by, etc. but no variables. Before this change variables never reached the where-clause visitor; now they change the generated SQL, so cached results can be reused across different variable values. [grounded: tree pkg/querybuilder/where_clause_visitor.go] [consensus 3/3: valid=3]
valid · matches d2 · impact high
valid · impact medium
When the exact lookup fails, the code drops the first byte of any string without checking for a '$' prefix, so 'prod' can resolve to a variable named 'rod'. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d4 · impact high
valid · matches d5 · impact medium
invalid
The only caller passes a qbtypes.VariableItem struct, not its Value. That falls through to the default case and returns "", so the []any branch that could panic is never reached through this path. [invalid: contradiction] [consensus 3/3: invalid=3]
valid · impact medium
applySeriesLimit returns early unless result.Value is *TimeSeriesData. processScalarFormula returns *ScalarData, so the scalar formula limit and order have no effect. [grounded: diff] [consensus 3/3: valid=3]
valid · impact medium
Unlike processTimeSeriesFormula, the new processScalarFormula never references formula.Functions, so declared functions are silently skipped for scalar formulas. [grounded: diff] [consensus 3/3: valid=3]
valid · impact low
Static intrinsic/calculated keys are appended after the SQL LIMIT is applied, so the result can exceed the requested limit. That also skews the Complete flag computed in fields/api.go. [grounded: diff] [consensus 3/3: valid=3]
valid · matches d3 · impact high
valid · matches d8 · impact medium
raw comments (12)
pkg/querier/querier.go:208
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 1\. Variable queries return cached results <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>QueryRange</i></b> now passes <b><i>tmplVars</i></b> into builder queries, but <b><i>builderQuery.Fingerprint</i></b> does not include any variable names, types, or values. Two otherwise identical cached requests in one organization can therefore reuse results generated with different filter variables. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Builder-query variables affect generated filters but are absent from the cache fingerprint, allowing requests with different variable values to share cached results. ## Fix Focus Areas - pkg/querier/querier.go[208-227] - pkg/querier/builder_query.go[49-128] ## Recommended Fix Add a deterministic, canonical representation of all variable names, types, and values to `builderQuery.Fingerprint`, sorting map keys and preserving value types so semantically different variables cannot collide. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querybuilder/where_clause_visitor.go:348
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 2\. Empty filter values crash requests <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> <b><i>VisitComparison</i></b> treats every string as a variable candidate and slices <b><i>var_[1:]</i></b> after an exact lookup fails without checking whether the value is empty or starts with <b><i>$</i></b>. Valid comparisons such as <b><i>service.name = &quot;&quot;</i></b>, <b><i>service.name = &#x27;&#x27;</i></b>, and <b><i>service.name IN &quot;&quot;</i></b> reach this path and panic instead of producing a filter, after which the API recovery handler returns a generic internal-error response. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Variable fallback lookup slices empty literal values, so valid empty quoted values panic instead of being passed unchanged to the condition builder. ## Fix Focus Areas - pkg/querybuilder/where_clause_visitor.go[339-348] - pkg/querybuilder/where_clause_visitor.go[420-437] ## Recommended Fix Only attempt the prefix-free variable lookup when the string is non-empty, begins with `$`, and contains a nonempty variable name; otherwise preserve the literal unchanged. Use the same guarded helper for scalar comparisons and the `IN`/`NOT IN` variable path, and add tests covering empty-string filters. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querybuilder/where_clause_visitor.go:428
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 3\. Literal filters resolve wrong variables <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>VisitComparison</i></b> retries every unmatched string by dropping its first byte rather than limiting that behavior to <b><i>$</i></b>-prefixed references. A literal such as <b><i>&quot;prod&quot;</i></b> is silently replaced when the request contains a variable named <b><i>rod</i></b>, changing both scalar and membership filter results. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Ordinary string literals are treated as variable references after their first byte is removed, allowing unrelated variables to alter filter semantics. ## Fix Focus Areas - pkg/querybuilder/where_clause_visitor.go[339-348] - pkg/querybuilder/where_clause_visitor.go[420-428] ## Recommended Fix Recognize variables only when the parsed value explicitly starts with `$`, then look up the name after that prefix. Leave all quoted and bare non-prefixed literals unchanged, and share this logic between membership and scalar comparisons. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querybuilder/where_clause_visitor.go:434
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 4\. Empty variables crash comparisons <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> The scalar variable branch reads <b><i>varValues[0]</i></b> whenever a variable value has type <b><i>[]any</i></b>, without checking its length. An empty multi-value variable used with equality, ordering, or another scalar operator therefore panics the query request. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Scalar comparisons index the first element of variable arrays without handling an empty array, causing a runtime panic. ## Fix Focus Areas - pkg/querybuilder/where_clause_visitor.go[420-436] ## Recommended Fix Check array length before selecting an element and return a typed invalid-input error for empty or multi-valued variables used with scalar operators. Propagate that error instead of reducing it to an empty condition. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querybuilder/where_clause_visitor.go:362
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 5\. Empty membership filters match all rows <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> The membership-variable branch replaces <b><i>values</i></b> with an empty array and then builds a condition from zero member predicates. For <b><i>field IN $var</i></b>, an empty multi-value variable consequently produces an empty condition that is omitted rather than an always-false predicate. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Empty array variables create no membership predicate, so an empty `IN` filter can be dropped and broaden the query to all rows. ## Fix Focus Areas - pkg/querybuilder/where_clause_visitor.go[339-379] - pkg/telemetrylogs/condition_builder.go[114-135] - pkg/telemetrymetrics/condition_builder.go[90-112] - pkg/telemetrytraces/condition_builder.go[103-125] ## Recommended Fix Handle empty membership values explicitly before invoking condition builders: emit an always-false expression for `IN` and an always-true expression for `NOT IN`. Add coverage for logs, metrics, traces, and resource filters. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querier/format.go:36
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 10\. Mixed variable arrays crash queries <code>🐞 Bug</code> <code>☼ Reliability</code> <pre> <b><i>formatValueForCH</i></b> chooses an array formatter from only the first element and then asserts every element has that same type. A JSON variable such as <b><i>[&#x27;a&#x27;, 1]</i></b> therefore panics while rendering a ClickHouse query instead of returning a validation error. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description ClickHouse variable formatting assumes all array elements match the first element and panics on mixed-type request arrays. ## Fix Focus Areas - pkg/querier/format.go[28-43] - pkg/querier/clickhouse_query.go[63-67] ## Recommended Fix Change variable formatting to return `(string, error)` and validate every array element before formatting it. Reject heterogeneous or unsupported arrays with a typed invalid-input error and propagate that error through ClickHouse rendering. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querier/postprocess.go:238
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 6\. Scalar formula limits are ignored <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>applyFormulas</i></b> passes the <b><i>ScalarData</i></b> returned by <b><i>processScalarFormula</i></b> to <b><i>applySeriesLimit</i></b>, which immediately returns unless the result contains <b><i>TimeSeriesData</i></b>. Any grouped scalar formula with a positive top or bottom limit therefore ignores its configured ordering and limit and returns every evaluated group. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Scalar formula results are converted to `ScalarData` before being passed to a time-series-only limiter, so configured top or bottom ordering and limits have no effect. ## Fix Focus Areas - pkg/querier/postprocess.go[177-191] - pkg/querier/postprocess.go[234-238] - pkg/querier/postprocess.go[422-472] ## Recommended Fix Apply the formula order and limit to `formulaSeries` while the evaluated result is still a slice of time series, before converting it to `ScalarData`; alternatively, add a scalar-aware implementation that sorts and truncates scalar rows using the formula order specification. Add a grouped scalar-formula test with a nonzero limit. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querier/postprocess.go:472
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 7\. Scalar formula functions are ignored <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>processScalarFormula</i></b> converts evaluated series directly to <b><i>ScalarData</i></b> and returns without applying <b><i>formula.Functions</i></b>. Scalar formulas using supported transformations such as absolute value or logarithms therefore return the untransformed expression result. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description The new scalar formula path returns immediately after evaluation and never applies the functions declared on the formula. ## Fix Focus Areas - pkg/querier/postprocess.go[290-302] - pkg/querier/postprocess.go[415-472] ## Recommended Fix Apply `formula.Functions` to the temporary time-series formula result before converting it back to scalar form, mirroring the time-series formula path. Define and validate behavior for functions that can add points before selecting the scalar output. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/telemetrymetadata/metadata.go:235
<img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> 11\. Field lookup exceeds requested limits <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>getTracesKeys</i></b> and <b><i>getLogsKeys</i></b> apply the selector limit only to database rows and then append every matching static field. Signal-specific key requests can consequently return more entries than requested, and the endpoint marks such responses incomplete even though another page repeats the same static additions. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` ## Issue description Static trace and log fields are appended after the database limit, allowing field-key responses to exceed the caller's requested limit. ## Fix Focus Areas - pkg/telemetrymetadata/metadata.go[217-237] - pkg/telemetrymetadata/metadata.go[370-389] - pkg/apis/fields/api.go[66-75] ## Recommended Fix Merge and deduplicate database and static keys first, then enforce the selector limit on the combined result. Compute completion from the total number of available combined keys rather than from an already oversized response. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querier/promql_query.go:67
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 8\. Dashboard variables render as empty values <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> Both raw-query <b><i>renderVars</i></b> implementations pass the <b><i>VariableItem</i></b> wrapper to <b><i>formatValueForCH</i></b> and <b><i>formatValueForProm</i></b> instead of passing <b><i>VariableItem.Value</i></b>, but neither formatter handles that wrapper type. Every non-reserved variable used in a raw ClickHouse or PromQL query is therefore replaced with an empty string before the query is executed. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` Issue description Raw PromQL and ClickHouse variable rendering formats `VariableItem` rather than its contained value, causing all non-reserved substitutions to become empty strings. Fix Focus Areas - pkg/querier/promql_query.go[64-67] - pkg/querier/clickhouse_query.go[63-67] Recommended Fix Pass `v.Value` to the respective formatter when populating `varsData`. Add coverage for string and array variables in both raw PromQL and ClickHouse queries. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
pkg/querybuilder/having_rewriter.go:115
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> 9\. Some aggregation filters fail to run <code>🐞 Bug</code> <code>≡ Correctness</code> <pre> <b><i>rewriteExpression</i></b> replaces quoted literals with placeholders before attempting to match aggregation-expression keys, so a mapping such as <b><i>countIf(level=&#x27;error&#x27;)</i></b> cannot match its now-placeholder-containing HAVING expression. When a user references an aggregation containing a string predicate, the builders emit the original source expression rather than the selected aggregate alias, leaving it to reference fields that were already rewritten for the SELECT clause. </pre> <details> <summary><strong>Agent Prompt</strong></summary> ``` Issue description HAVING rewriting masks quoted literals before matching aggregation expressions, preventing expressions such as `countIf(level='error')` from being replaced by their result columns. Fix Focus Areas - pkg/querybuilder/having_rewriter.go[106-150] - pkg/telemetrylogs/statement_builder.go[384-390] - pkg/telemetrytraces/statement_builder.go[423-427] Recommended Fix Rewrite complete aggregation-expression mappings against the original expression before protecting quoted literals, or normalize both mapping keys and candidate expressions with the same placeholder transformation. Add tests for direct `countIf` and other quoted-predicate aggregation references. ``` <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> </details>
PR-level
<h3>Code Review by Qodo</h3> <code>🐞 Bugs (11)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <br/> <img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required"> <details> <summary> 1. Variable queries return cached results <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>QueryRange</i></b> now passes <b><i>tmplVars</i></b> into builder queries, but <b><i>builderQuery.Fingerprint</i></b> does not >include any variable names, types, or values. Two otherwise identical cached requests in one >organization can therefore reuse results generated with different filter variables. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querier/querier.go[208]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-a0b881d1b7b99f439716f189b50eef90ccdaea00845b087c0dbce0e148aa2c0eR208-R208)</code> > >```diff >+ bq := newBuilderQuery(q.telemetryStore, q.traceStmtBuilder, spec, timeRange, req.RequestType, tmplVars) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The changed code supplies variables to every builder query, and those variables are later resolved >into filter values, while the builder fingerprint only includes the static query specification. The >execution path uses that fingerprint to select the bucket cache, so variable-dependent executions >currently share the same key. ></pre> > > <code>[pkg/querier/querier.go[203-227]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/querier.go/#L203-L227)</code> > <code>[pkg/querier/builder_query.go[49-128]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/builder_query.go/#L49-L128)</code> > <code>[pkg/querier/builder_query.go[180-181]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/builder_query.go/#L180-L181)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[339-363]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L339-L363)</code> > <code>[pkg/querier/querier.go[243-265]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/querier.go/#L243-L265)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Builder-query variables affect generated filters but are absent from the cache fingerprint, allowing requests with different variable values to share cached results. > >## Fix Focus Areas >- pkg/querier/querier.go[208-227] >- pkg/querier/builder_query.go[49-128] > >## Recommended Fix >Add a deterministic, canonical representation of all variable names, types, and values to `builderQuery.Fingerprint`, sorting map keys and preserving value types so semantically different variables cannot collide. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 2. Empty filter values crash requests <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>VisitComparison</i></b> treats every string as a variable candidate and slices <b><i>var_[1:]</i></b> after an exact >lookup fails without checking whether the value is empty or starts with <b><i>$</i></b>. Valid comparisons such >as <b><i>service.name = &quot;&quot;</i></b>, <b><i>service.name = &#x27;&#x27;</i></b>, and <b><i>service.name IN &quot;&quot;</i></b> reach this path and panic >instead of producing a filter, after which the API recovery handler returns a generic internal-error >response. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querybuilder/where_clause_visitor.go[R346-348]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-681324297615d316475424f2d7acead310b801737d688250dd46a5c45bd82f3eR346-R348)</code> > >```diff >+ if !ok { >+ varItem, ok = v.variables[var_[1:]] >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The grammar accepts zero characters inside quoted text, and the visitor strips the quotes to produce >an empty string. Both newly added variable-resolution branches perform an unchecked slice at byte >index one after an unsuccessful lookup, which panics when applied to that empty string; the HTTP >handler&#x27;s recovery path then converts the panic into an internal-error response. ></pre> > > <code>[grammar/FilterQuery.g4[129-137]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/grammar/FilterQuery.g4/#L129-L137)</code> > <code>[grammar/FilterQuery.g4[204-208]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/grammar/FilterQuery.g4/#L204-L208)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[339-348]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L339-L348)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[420-428]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L420-L428)</code> > <code>[grammar/FilterQuery.g4[204-209]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/grammar/FilterQuery.g4/#L204-L209)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[420-437]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L420-L437)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[636-661]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L636-L661)</code> > <code>[pkg/querier/api.go[41-58]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/api.go/#L41-L58)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Variable fallback lookup slices empty literal values, so valid empty quoted values panic instead of being passed unchanged to the condition builder. > >## Fix Focus Areas >- pkg/querybuilder/where_clause_visitor.go[339-348] >- pkg/querybuilder/where_clause_visitor.go[420-437] > >## Recommended Fix >Only attempt the prefix-free variable lookup when the string is non-empty, begins with `$`, and contains a nonempty variable name; otherwise preserve the literal unchanged. Use the same guarded helper for scalar comparisons and the `IN`/`NOT IN` variable path, and add tests covering empty-string filters. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 3. Literal filters resolve wrong variables <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>VisitComparison</i></b> retries every unmatched string by dropping its first byte rather than limiting >that behavior to <b><i>$</i></b>-prefixed references. A literal such as <b><i>&quot;prod&quot;</i></b> is silently replaced when the >request contains a variable named <b><i>rod</i></b>, changing both scalar and membership filter results. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querybuilder/where_clause_visitor.go[R425-428]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-681324297615d316475424f2d7acead310b801737d688250dd46a5c45bd82f3eR425-R428)</code> > >```diff >+ // if not present, try without `$` prefix >+ if !ok { >+ varItem, ok = v.variables[var_[1:]] >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Both lookup branches first try the full literal and then unconditionally try its suffix beginning at >byte one. Because the request variable map accepts arbitrary names, an unrelated suffix key can >match and replace the original literal. ></pre> > > <code>[pkg/querybuilder/where_clause_visitor.go[339-363]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L339-L363)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[420-436]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L420-L436)</code> > <code>[pkg/types/querybuildertypes/querybuildertypesv5/req.go[189-206]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/req.go/#L189-L206)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Ordinary string literals are treated as variable references after their first byte is removed, allowing unrelated variables to alter filter semantics. > >## Fix Focus Areas >- pkg/querybuilder/where_clause_visitor.go[339-348] >- pkg/querybuilder/where_clause_visitor.go[420-428] > >## Recommended Fix >Recognize variables only when the parsed value explicitly starts with `$`, then look up the name after that prefix. Leave all quoted and bare non-prefixed literals unchanged, and share this logic between membership and scalar comparisons. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details><summary><ins><strong>View high (6)</strong></ins></summary><br/> <details> <summary> 4. Empty variables crash comparisons <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The scalar variable branch reads <b><i>varValues[0]</i></b> whenever a variable value has type <b><i>[]any</i></b>, without >checking its length. An empty multi-value variable used with equality, ordering, or another scalar >operator therefore panics the query request. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querybuilder/where_clause_visitor.go[R431-434]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-681324297615d316475424f2d7acead310b801737d688250dd46a5c45bd82f3eR431-R434)</code> > >```diff >+ switch varValues := varItem.Value.(type) { >+ case []any: >+ value = varValues[0] >+ case any: >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Variable values are untyped request data and may legally decode as an empty <b><i>[]any</i></b>; the new scalar >substitution directly accesses index zero. The surrounding comparison path provides no preceding >validation or length guard. ></pre> > > <code>[pkg/types/querybuildertypes/querybuildertypesv5/req.go[189-206]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/req.go/#L189-L206)</code> > <code>[pkg/querybuilder/where_clause_visitor.go[415-437]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L415-L437)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Scalar comparisons index the first element of variable arrays without handling an empty array, causing a runtime panic. > >## Fix Focus Areas >- pkg/querybuilder/where_clause_visitor.go[420-436] > >## Recommended Fix >Check array length before selecting an element and return a typed invalid-input error for empty or multi-valued variables used with scalar operators. Propagate that error instead of reducing it to an empty condition. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 5. Empty membership filters match all rows <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >The membership-variable branch replaces <b><i>values</i></b> with an empty array and then builds a condition >from zero member predicates. For <b><i>field IN $var</i></b>, an empty multi-value variable consequently >produces an empty condition that is omitted rather than an always-false predicate. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querybuilder/where_clause_visitor.go[R358-362]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-681324297615d316475424f2d7acead310b801737d688250dd46a5c45bd82f3eR358-R362)</code> > >```diff >+ switch varValues := varItem.Value.(type) { >+ case []any: >+ values = varValues >+ case any: >+ values = []any{varValues} >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The visitor accepts the empty variable array and passes it to each signal&#x27;s condition builder. Those >builders construct membership expressions by combining one predicate per value, so no predicate >exists for an empty set and the visitor ultimately returns an empty condition. ></pre> > > <code>[pkg/querybuilder/where_clause_visitor.go[339-383]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/where_clause_visitor.go/#L339-L383)</code> > <code>[pkg/telemetrylogs/condition_builder.go[114-135]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrylogs/condition_builder.go/#L114-L135)</code> > <code>[pkg/telemetrymetrics/condition_builder.go[90-112]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetrics/condition_builder.go/#L90-L112)</code> > <code>[pkg/telemetrytraces/condition_builder.go[103-125]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrytraces/condition_builder.go/#L103-L125)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Empty array variables create no membership predicate, so an empty `IN` filter can be dropped and broaden the query to all rows. > >## Fix Focus Areas >- pkg/querybuilder/where_clause_visitor.go[339-379] >- pkg/telemetrylogs/condition_builder.go[114-135] >- pkg/telemetrymetrics/condition_builder.go[90-112] >- pkg/telemetrytraces/condition_builder.go[103-125] > >## Recommended Fix >Handle empty membership values explicitly before invoking condition builders: emit an always-false expression for `IN` and an always-true expression for `NOT IN`. Add coverage for logs, metrics, traces, and resource filters. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 6. Scalar formula limits are ignored <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>applyFormulas</i></b> passes the <b><i>ScalarData</i></b> returned by <b><i>processScalarFormula</i></b> to <b><i>applySeriesLimit</i></b>, >which immediately returns unless the result contains <b><i>TimeSeriesData</i></b>. Any grouped scalar formula >with a positive top or bottom limit therefore ignores its configured ordering and limit and returns >every evaluated group. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querier/postprocess.go[R235-238]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-607aeb957d880e2851b920f66fdcb855b9552f23eeb6e002ce25e185d287cf63R235-R238)</code> > >```diff >+ result := q.processScalarFormula(ctx, results, formula, req) >+ if result != nil { >+ result = q.applySeriesLimit(result, formula.Limit, formula.Order) > results[name] = result >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The scalar formula branch explicitly calls <b><i>applySeriesLimit</i></b>, but <b><i>processScalarFormula</i></b> constructs >and returns <b><i>ScalarData</i></b>, while the limiter only type-asserts and operates on <b><i>TimeSeriesData</i></b>. The >assertion therefore fails and returns the result unchanged, so the actual ordering and limit >operation is never invoked for scalar formulas, even when the schema specifies a positive limit. ></pre> > > <code>[pkg/querier/postprocess.go[177-191]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L177-L191)</code> > <code>[pkg/querier/postprocess.go[225-240]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L225-L240)</code> > <code>[pkg/querier/postprocess.go[428-472]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L428-L472)</code> > <code>[pkg/types/querybuildertypes/querybuildertypesv5/formula.go[17-33]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/formula.go/#L17-L33)</code> > <code>[pkg/querier/postprocess.go[177-192]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L177-L192)</code> > <code>[pkg/querier/postprocess.go[212-240]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L212-L240)</code> > <code>[pkg/types/querybuildertypes/querybuildertypesv5/series_limit.go[16-73]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/series_limit.go/#L16-L73)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Scalar formula results are converted to `ScalarData` before being passed to a time-series-only limiter, so configured top or bottom ordering and limits have no effect. > >## Fix Focus Areas >- pkg/querier/postprocess.go[177-191] >- pkg/querier/postprocess.go[234-238] >- pkg/querier/postprocess.go[422-472] > >## Recommended Fix >Apply the formula order and limit to `formulaSeries` while the evaluated result is still a slice of time series, before converting it to `ScalarData`; alternatively, add a scalar-aware implementation that sorts and truncates scalar rows using the formula order specification. Add a grouped scalar-formula test with a nonzero limit. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 7. Scalar formula functions are ignored <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>processScalarFormula</i></b> converts evaluated series directly to <b><i>ScalarData</i></b> and returns without >applying <b><i>formula.Functions</i></b>. Scalar formulas using supported transformations such as absolute value >or logarithms therefore return the untransformed expression result. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querier/postprocess.go[R470-472]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-607aeb957d880e2851b920f66fdcb855b9552f23eeb6e002ce25e185d287cf63R470-R472)</code> > >```diff >+ return &qbtypes.Result{ >+ Value: scalarResult, >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >The time-series formula path prepares and applies all declared functions, whereas the scalar path >evaluates, converts, and returns without referencing them. The formula request type exposes the same ><b><i>Functions</i></b> field regardless of request type. ></pre> > > <code>[pkg/querier/postprocess.go[290-302]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L290-L302)</code> > <code>[pkg/querier/postprocess.go[415-472]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/postprocess.go/#L415-L472)</code> > <code>[pkg/types/querybuildertypes/querybuildertypesv5/formula.go[17-33]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/formula.go/#L17-L33)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >The new scalar formula path returns immediately after evaluation and never applies the functions declared on the formula. > >## Fix Focus Areas >- pkg/querier/postprocess.go[290-302] >- pkg/querier/postprocess.go[415-472] > >## Recommended Fix >Apply `formula.Functions` to the temporary time-series formula result before converting it back to scalar form, mirroring the time-series formula path. Define and validate behavior for functions that can add points before selecting the scalar output. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 8. Dashboard variables render as empty values <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> >Both raw-query <b><i>renderVars</i></b> implementations pass the <b><i>VariableItem</i></b> wrapper to <b><i>formatValueForCH</i></b> >and <b><i>formatValueForProm</i></b> instead of passing <b><i>VariableItem.Value</i></b>, but neither formatter handles that >wrapper type. Every non-reserved variable used in a raw ClickHouse or PromQL query is therefore >replaced with an empty string before the query is executed. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querier/promql_query.go[R64-67]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-917be2f02ede5084ffd1ec5d4eeb3aad1fb34958bcb1db98bda403ef655a020dR64-R67)</code> > >```diff >+ varsData := map[string]any{} >+ for k, v := range vars { >+ varsData[k] = formatValueForProm(v) >+ } >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> ><b><i>VariableItem</i></b> stores the actual selection in <b><i>Value</i></b>, while both renderers pass the wrapper to >formatters whose default branch returns an empty string. The rendered text is then used directly for >execution. ></pre> > > <code>[pkg/types/querybuildertypes/querybuildertypesv5/req.go[189-192]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/req.go/#L189-L192)</code> > <code>[pkg/querier/format.go[18-52]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/format.go/#L18-L52)</code> > <code>[pkg/querier/format.go[152-180]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/format.go/#L152-L180)</code> > <code>[pkg/querier/promql_query.go[63-97]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/promql_query.go/#L63-L97)</code> > <code>[pkg/querier/clickhouse_query.go[63-97]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/clickhouse_query.go/#L63-L97)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >Issue description >Raw PromQL and ClickHouse variable rendering formats `VariableItem` rather than its contained value, causing all non-reserved substitutions to become empty strings. > >Fix Focus Areas >- pkg/querier/promql_query.go[64-67] >- pkg/querier/clickhouse_query.go[63-67] > >Recommended Fix >Pass `v.Value` to the respective formatter when populating `varsData`. Add coverage for string and array variables in both raw PromQL and ClickHouse queries. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 9. Some aggregation filters fail to run <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>rewriteExpression</i></b> replaces quoted literals with placeholders before attempting to match >aggregation-expression keys, so a mapping such as <b><i>countIf(level=&#x27;error&#x27;)</i></b> cannot match its >now-placeholder-containing HAVING expression. When a user references an aggregation containing a >string predicate, the builders emit the original source expression rather than the selected >aggregate alias, leaving it to reference fields that were already rewritten for the SELECT clause. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querybuilder/having_rewriter.go[R111-115]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-6df6c9cd734e2d1d6c6ae9a8b07dbc3f7ec1fcd99d281a645bfccb4ed9f8d22cR111-R115)</code> > >```diff >+ expression = quotePattern.ReplaceAllStringFunc(expression, func(match string) string { >+ placeholder := fmt.Sprintf("__QUOTED_%d__", quotedIdx) >+ quotedStrings[placeholder] = match >+ quotedIdx++ >+ return placeholder >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Quoted text is replaced before mapping but restored only afterward, making aggregation keys >containing literals impossible to match. Aggregation rewriting separately transforms <b><i>*If</i></b> >predicates into physical field expressions, so leaving the original expression in HAVING is not >equivalent to using the selected result alias. ></pre> > > <code>[pkg/querybuilder/having_rewriter.go[106-150]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/having_rewriter.go/#L106-L150)</code> > <code>[pkg/querybuilder/agg_rewrite.go[179-224]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querybuilder/agg_rewrite.go/#L179-L224)</code> > <code>[pkg/telemetrylogs/statement_builder.go[357-390]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrylogs/statement_builder.go/#L357-L390)</code> > <code>[pkg/telemetrytraces/statement_builder.go[393-427]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrytraces/statement_builder.go/#L393-L427)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >Issue description >HAVING rewriting masks quoted literals before matching aggregation expressions, preventing expressions such as `countIf(level='error')` from being replaced by their result columns. > >Fix Focus Areas >- pkg/querybuilder/having_rewriter.go[106-150] >- pkg/telemetrylogs/statement_builder.go[384-390] >- pkg/telemetrytraces/statement_builder.go[423-427] > >Recommended Fix >Rewrite complete aggregation-expression mappings against the original expression before protecting quoted literals, or normalize both mapping keys and candidate expressions with the same placeholder transformation. Add tests for direct `countIf` and other quoted-predicate aggregation references. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> </details> <br/> <img src="https://img.shields.io/badge/Medium-634FD1?style=flat-square" height="20px" alt="Remediation recommended"> <details> <summary> 10. Mixed variable arrays crash queries <code>🐞 Bug</code> <code>☼ Reliability</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>formatValueForCH</i></b> chooses an array formatter from only the first element and then asserts every >element has that same type. A JSON variable such as <b><i>[&#x27;a&#x27;, 1]</i></b> therefore panics while rendering a >ClickHouse query instead of returning a validation error. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/querier/format.go[R32-36]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-343a4b679c8a1b820cde188cad8c388bfb302c5ed8c05e30baa0ca497c897ac0R32-R36)</code> > >```diff >+ switch x[0].(type) { >+ case string: >+ strs := []string{} >+ for _, sVal := range x { >+ strs = append(strs, fmt.Sprintf("'%s'", quoteEscapedString(sVal.(string)))) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Request variables permit arbitrary values, while the string-array branch performs <b><i>sVal.(string)</i></b> >for every element after inspecting only <b><i>x[0]</i></b>. Every supplied ClickHouse variable passes through >this function before execution, making the panic reachable from an HTTP request. ></pre> > > <code>[pkg/types/querybuildertypes/querybuildertypesv5/req.go[189-206]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/types/querybuildertypes/querybuildertypesv5/req.go/#L189-L206)</code> > <code>[pkg/querier/format.go[28-43]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/format.go/#L28-L43)</code> > <code>[pkg/querier/clickhouse_query.go[63-67]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/clickhouse_query.go/#L63-L67)</code> > <code>[pkg/querier/api.go[41-58]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/querier/api.go/#L41-L58)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >ClickHouse variable formatting assumes all array elements match the first element and panics on mixed-type request arrays. > >## Fix Focus Areas >- pkg/querier/format.go[28-43] >- pkg/querier/clickhouse_query.go[63-67] > >## Recommended Fix >Change variable formatting to return `(string, error)` and validate every array element before formatting it. Reject heterogeneous or unsupported arrays with a typed invalid-input error and propagate that error through ClickHouse rendering. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <details> <summary> 11. Field lookup exceeds requested limits <code>🐞 Bug</code> <code>≡ Correctness</code></summary> <br/> > <details open> ><summary>Description</summary> ><br/> > ><pre> ><b><i>getTracesKeys</i></b> and <b><i>getLogsKeys</i></b> apply the selector limit only to database rows and then append >every matching static field. Signal-specific key requests can consequently return more entries than >requested, and the endpoint marks such responses incomplete even though another page repeats the >same static additions. ></pre> ></details> > <details> ><summary>Code</summary> ><br/> > ><code>[pkg/telemetrymetadata/metadata.go[R230-235]](https://github.com/drape-io/crbench-qodo-2026-09/pull/78/files#diff-87cd9d014a84aecb4270474cd9db56ee84e925b2ea0c533f3823532e69be9d48R230-R235)</code> > >```diff >+ if found { >+ keys = append(keys, &telemetrytypes.TelemetryFieldKey{ >+ Name: key, >+ FieldContext: telemetrytypes.FieldContextSpan, >+ Signal: telemetrytypes.SignalTraces, >+ }) >``` ></details> > <details> ><summary>Evidence</summary> ><br/> > ><pre> >Both metadata queries apply their SQL limit before these newly added loops, and neither loop checks >the remaining capacity before appending static keys. <b><i>GetKeys</i></b> groups all appended entries into the >returned map, whose size is then compared with the requested limit by the HTTP endpoint. ></pre> > > <code>[pkg/telemetrymetadata/metadata.go[175-179]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetadata/metadata.go/#L175-L179)</code> > <code>[pkg/telemetrymetadata/metadata.go[217-237]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetadata/metadata.go/#L217-L237)</code> > <code>[pkg/telemetrymetadata/metadata.go[328-332]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetadata/metadata.go/#L328-L332)</code> > <code>[pkg/telemetrymetadata/metadata.go[370-389]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetadata/metadata.go/#L370-L389)</code> > <code>[pkg/telemetrymetadata/metadata.go[481-528]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/telemetrymetadata/metadata.go/#L481-L528)</code> > <code>[pkg/apis/fields/api.go[66-75]](https://github.com/drape-io/crbench-qodo-2026-09/blob/875740640995b46b79df1d555eec21ea46c37c03/pkg/apis/fields/api.go/#L66-L75)</code> ></details> > <details> ><summary>Agent prompt</summary> ><br/> > >``` >The issue below was found during a code review. Follow the provided context and guidance below and implement a solution > >## Issue description >Static trace and log fields are appended after the database limit, allowing field-key responses to exceed the caller's requested limit. > >## Fix Focus Areas >- pkg/telemetrymetadata/metadata.go[217-237] >- pkg/telemetrymetadata/metadata.go[370-389] >- pkg/apis/fields/api.go[66-75] > >## Recommended Fix >Merge and deduplicate database and static keys first, then enforce the selector limit on the combined result. Compute completion from the total number of available combined keys rather than from an already oversized response. >``` > <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code> ></details> <hr/> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-context:start --> <details><summary><strong>Context sources</strong></summary> <div>Review mode: <code>🧠 Deep</code>: This is a broad, behavior-heavy query-service change spanning parsing, variable interpolation, SQL/PromQL generation, filtering, aggregation, formulas, and multiple telemetry paths, with many independent logic sites where subtle defects could be missed in one pass.</div> <!-- qodo-context:end --> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:start --> <details> <summary><strong>Tip of the day</strong></summary> <br/> <pre>💡 Did you know, you can reply &#x27;qodo&#x27; on any finding to push back, ask questions, or dig deeper</pre> <a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a> </details> <img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider"> <!-- qodo-daily-tip:end --> <!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/875740640995b46b79df1d555eec21ea46c37c03 --> <a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>