Repository navigation
fix: prevent groupByNode panics on empty callback results - #579
Merged
Merged
Conversation
timtofan
force-pushed
the
atimofieiev/group-by-node-empty-input
branch
from
October 21, 2026 09:12
3d50b42 to
aba1ab6
Compare
deniszh
approved these changes
Oct 21, 2026
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 issue is this change attempting to solve?
Why
groupByNodeandgroupByNodespanic when a callback returns a non-nil slice containing zero series. The existing nil check lets that result reachr[0], turning expression evaluation into an index-out-of-range error. The expression evaluator can return this result shape when its context is cancelled.How does this change solve the problem? Why is this the best approach?
Architecture
This is a local change to expression grouping. Group construction and callback evaluation keep their current boundaries and error-handling behavior. Check the result length before renaming its first series and appending the callback output.
Before / after
r[0]A non-empty series whose points are all null remains present. This guard operates on the number of returned series, rather than their point values.
How can we be sure this works as expected?
go test ./pkg/expr/functions/groupByNode -count=1passed.make testpassed: 50 packages tested with-tags cairo,nativegzip -race.golangci-lintv2.14.0 passed for the full repository with zero issues.