yq
yq copied to clipboard
Data structures not representable in output format should result in an error.
Describe the bug
YAML can represent data structures that other formats supported by yq
cannot, for example, graphs of objects that have cycles in them.
Here's a YAML representation of an array containing a single element: itself.
---
&1
- *1
If I ask yq
to give me the JSON representation, it gives incorrect output.
> yq --output-format json . self-referential.yaml
[
[
[]
]
]
The problem is that the input is not properly representable in JSON. This should produce an error.
Version of yq: 4.44.3 Operating system: macOS 14.7 Installed via: homebrew
Input YAML
data1.yml:
---
&1
- *1
Command
yq --output-format json . data1.yml
Actual behavior
[
[
[]
]
]
with an exit code of 0
.
Expected behavior
Error with a non-0
exit code.
Additional context
None.