Repository navigation
fix(traceql): render an empty selector without panicking - #1057
Merged
rita7lopes merged 1 commit intoNov 3, 2026
Merged
Conversation
Selector.String() dereferenced AttrSelector, which is nil for an empty
selector, so String() panicked on valid queries such as `{ }`,
`{ } | rate()` and `{ } && { .a = 1 }`. It now renders `{}`, as
CompareSelector.String() already does.
AttrSelectorExp.String() likewise dereferenced Tail whenever AndOr was
set. The parser accepts `{ .a = 1 && }` (not valid TraceQL) with a nil
Tail; String() no longer panics on it. Whether the parser should accept
that input is left for a separate change.
Queries that rendered before render exactly as before: of 72 TraceQL
queries, the only outputs that changed are the 8 that used to panic.
This was referenced Oct 29, 2026
rita7lopes
approved these changes
Nov 3, 2026
rita7lopes
left a comment
Contributor
There was a problem hiding this comment.
Not a real user impact thing but merging because of #1059
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two nil checks in
reader/traceql/traceql_parser/model_v2.go, plus tests:Selector.String()renders an empty selector as{}, asCompareSelector.String()already does. It used to dereference the nilAttrSelector.AttrSelectorExp.String()no longer dereferences a nilTailwhenAndOris set.Why
String()panicked on valid queries with an empty selector:{},{ }{}{ } | rate(){} | rate(){ } | count() > 1{} | count() > 1{ } && { .a = 1 }{} && {.a = 1}({ })({})It was found while adding parse-render round-trip checks to the parser fuzz targets for M1 (#918).
Impact on users is low. The transpiler does not render the AST on the query path. The only production caller is an error message in
clickhouse_transpiler/attr_condition.go.The parser also accepts
{ .a = 1 && }and{ .a = 1 || }, which are not valid TraceQL, and leavesTailnil. The second nil check stopsString()from panicking on them. Whether the parser should reject that input is a separate change, not made here.Verification
model_v2_test.go:&&/||queries must not panicmasterand pass here.masterand on this branch. 64 render identically. The other 8 are the ones that used to panic.gofmt -l .is clean.go build,go test ./...andgo test -race ./reader/traceql/...pass.go vet ./...gives the same findings asmaster. The pre-existing participle struct-tag warnings inmodel_v2.gomoved down by the added lines.