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
When converting an array to XML, yq exits with a panic.
Version of yq: 4.29.2
Operating system: mac
Installed via: homebrew
Command
yq -o x . <<<'[5]'
Actual behavior
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
github.com/mikefarah/yq/v4/pkg/yqlib.(*xmlEncoder).encodeTopLevelMap(0x14000396d00, 0x0?, 0x140003acb40)
github.com/mikefarah/yq/v4/pkg/yqlib/encoder_xml.go:95 +0x7ec
github.com/mikefarah/yq/v4/pkg/yqlib.(*xmlEncoder).Encode(0x14000396d00, {0x1033ff888?, 0x140000136c0?}, 0x140003aca00)
github.com/mikefarah/yq/v4/pkg/yqlib/encoder_xml.go:68 +0x324
github.com/mikefarah/yq/v4/pkg/yqlib.(*resultsPrinter).printNode(0x14000396d00?, 0x0?, {0x1033ff888?, 0x140000136c0?})
github.com/mikefarah/yq/v4/pkg/yqlib/printer.go:82 +0x100
github.com/mikefarah/yq/v4/pkg/yqlib.(*resultsPrinter).PrintResults(0x14000072540, 0x140003aa540)
github.com/mikefarah/yq/v4/pkg/yqlib/printer.go:133 +0x568
...
Expected behavior
Either
a proper error message ("Arrays cannot be converted to XML")
or nothing (which is the current behavior for other not-representable data formats, e.g. yq -o x . <<< 5 does not output anything and signals no error)
The text was updated successfully, but these errors were encountered:
Describe the bug
When converting an array to XML, yq exits with a panic.
Version of yq: 4.29.2
Operating system: mac
Installed via: homebrew
Command
Actual behavior
Expected behavior
Either
yq -o x . <<< 5
does not output anything and signals no error)The text was updated successfully, but these errors were encountered: