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

Data structures not representable in output format should result in an error. #2167

Open
clonezone opened this issue Oct 10, 2024 · 0 comments
Labels

Comments

@clonezone
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@clonezone and others