You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Attempting to use the filtered value (i.e node.String() or ast.Walk) of a path which combines IndexAll and Child might lead to seg fault if not all sequence elements contain the property being selected by Child
Taking jq as inspiration, partial results should be returned, possibly with nil elements:
$ echo'[{"foo": 1}, {}]'| jq ".[].foo"
1
null
Screenshots
Version Variables
Go version: go version go1.22.1 linux/amd64
go-yaml's Version: (tag: v1.11.3) and main
Additional context
I have a tentative fix in this branch master...cezarguimaraes:go-yaml:fix-indexAll-child-segfault
As can be seen by the tests added, the code from this branch simulates jq behavior by returning ast.Null. Another possible approach (preserved by the comments in (*indexAllNode).filter completely filter out unmatched nodes.
The text was updated successfully, but these errors were encountered:
Describe the bug
Attempting to use the filtered value (i.e
node.String()
orast.Walk
) of a path which combinesIndexAll
andChild
might lead to seg fault if not all sequence elements contain the property being selected byChild
To Reproduce
https://go.dev/play/p/hxD0l_fdVYO
I have added a test case here that reproduces the issue
cezarguimaraes@19b7508
Expected behavior
Taking
jq
as inspiration, partial results should be returned, possibly withnil
elements:Screenshots
Version Variables
go version go1.22.1 linux/amd64
(tag: v1.11.3)
and mainAdditional context
I have a tentative fix in this branch master...cezarguimaraes:go-yaml:fix-indexAll-child-segfault
As can be seen by the tests added, the code from this branch simulates
jq
behavior by returningast.Null
. Another possible approach (preserved by the comments in(*indexAllNode).filter
completely filter out unmatched nodes.The text was updated successfully, but these errors were encountered: