Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic when mutiple assign to multi documents #1256

Closed
care0717 opened this issue Jun 24, 2022 · 0 comments · Fixed by #1257
Closed

panic when mutiple assign to multi documents #1256

care0717 opened this issue Jun 24, 2022 · 0 comments · Fixed by #1257
Labels

Comments

@care0717
Copy link
Contributor

care0717 commented Jun 24, 2022

Describe the bug
I've got panic when I use multiple assign to multi documents.

Version of yq: 4.25.2
Operating system: mac
Installed via: homebrew

Input Yaml
sample.yml:

a: 1
---
b: 2

Command

yq '. *= {"c":3}' sample.yaml

Actual behavior
output

a: 1
c: 3
panic: interface conversion: interface {} is nil, not yqlib.multiplyPreferences

goroutine 1 [running]:
github.com/mikefarah/yq/v4/pkg/yqlib.multiplyOperator(0xc000013890?, {0xc0004612f0, 0xc000461380, 0x1, {0x0, 0x0}}, 0xc0003b8c30)
	github.com/mikefarah/yq/v4/pkg/yqlib/operator_multiply.go:37 +0x205
github.com/mikefarah/yq/v4/pkg/yqlib.(*dataTreeNavigator).GetMatchingNodes(0xc000461380?, {0xc0004612f0, 0xc000461380, 0x1, {0x0, 0x0}}, 0xc0003b8c30)
	github.com/mikefarah/yq/v4/pkg/yqlib/data_tree_navigator.go:37 +0x25c
github.com/mikefarah/yq/v4/pkg/yqlib.resultsForRHS(0x19?, {0xc0004612f0, 0xc000461380, 0x1, {0x0, 0x0}}, 0x28?, {0x0, 0x0, 0xc00045e920}, ...)
	github.com/mikefarah/yq/v4/pkg/yqlib/operators.go:69 +0x1fc
github.com/mikefarah/yq/v4/pkg/yqlib.doCrossFunc(0x1d?, {0xc0004612f0, 0xc000461380, 0x1, {0x0, 0x0}}, 0xc0003b8c48, {0x0, 0x0, 0xc00045e920})
	github.com/mikefarah/yq/v4/pkg/yqlib/operators.go:125 +0x413
github.com/mikefarah/yq/v4/pkg/yqlib.crossFunctionWithPrefs(0x1?, {0xc000461260, 0x0, 0x1, {0x0, 0x0}}, 0x1e00108?, {0x0, 0x0, 0xc00045e920})
	github.com/mikefarah/yq/v4/pkg/yqlib/operators.go:158 +0x3db
github.com/mikefarah/yq/v4/pkg/yqlib.crossFunction(0x110230f?, {0xc000461260, 0x0, 0x1, {0x0, 0x0}}, 0xc0003b8c18?, 0x0?, 0xf0?)
	github.com/mikefarah/yq/v4/pkg/yqlib/operators.go:136 +0x9f
github.com/mikefarah/yq/v4/pkg/yqlib.assignUpdateOperator(0xc000013890?, {0xc000460ed0, 0x0, 0x0, {0x0, 0x0}}, 0xc0003b8c48)
	github.com/mikefarah/yq/v4/pkg/yqlib/operator_assign.go:31 +0x305
github.com/mikefarah/yq/v4/pkg/yqlib.(*dataTreeNavigator).GetMatchingNodes(0xc0003b8c00?, {0xc000460ed0, 0x0, 0x0, {0x0, 0x0}}, 0xc0003b8c48)
	github.com/mikefarah/yq/v4/pkg/yqlib/data_tree_navigator.go:37 +0x25c
github.com/mikefarah/yq/v4/pkg/yqlib.compoundAssignFunction(0x13a0020?, {0xc000460ed0, 0x0, 0x0, {0x0, 0x0}}, 0xc0003b8840, 0xc0004276f0)
	github.com/mikefarah/yq/v4/pkg/yqlib/operators.go:35 +0x3ba
github.com/mikefarah/yq/v4/pkg/yqlib.multiplyAssignOperator(0xc000013890?, {0xc000460ed0, 0x0, 0x0, {0x0, 0x0}}, 0x0?)
	github.com/mikefarah/yq/v4/pkg/yqlib/operator_multiply.go:32 +0xe8
github.com/mikefarah/yq/v4/pkg/yqlib.(*dataTreeNavigator).GetMatchingNodes(0x0?, {0xc000460ed0, 0x0, 0x0, {0x0, 0x0}}, 0xc0003b8840)
	github.com/mikefarah/yq/v4/pkg/yqlib/data_tree_navigator.go:37 +0x25c
github.com/mikefarah/yq/v4/pkg/yqlib.(*streamEvaluator).Evaluate(0xc000427cf0, {0x7ffeefbff948, 0xb}, {0x143cc20?, 0xc0003ddf80?}, 0x1fe52c0?, {0x143e8d0, 0xc0003dde60}, {0x0, 0x0}, ...)
	github.com/mikefarah/yq/v4/pkg/yqlib/stream_evaluator.go:124 +0x35c
github.com/mikefarah/yq/v4/pkg/yqlib.(*streamEvaluator).EvaluateFiles(0xc000010018?, {0x7ffeefbff93b, 0xc}, {0xc00006e610, 0x1, 0x6?}, {0x143e8d0, 0xc0003dde60}, 0x2?, {0x143dde0, ...})
	github.com/mikefarah/yq/v4/pkg/yqlib/stream_evaluator.go:73 +0x30e
github.com/mikefarah/yq/v4/cmd.evaluateSequence(0xc000015900?, {0xc00006e600, 0x2, 0x2})
	github.com/mikefarah/yq/v4/cmd/evalute_sequence_command.go:132 +0x8a5
github.com/spf13/cobra.(*Command).execute(0xc000015900, {0xc00006e5a0, 0x2, 0x2})
	github.com/spf13/cobra@v1.4.0/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000015680)
	github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.4.0/command.go:902
main.main()
	github.com/mikefarah/yq/v4/yq.go:22 +0x1f1

Expected behavior

a: 1
c: 3
---
b: 2
c: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant