-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
YAML on/off as keys cannot be queried correctly #5754
Comments
Thanks for reporting this, @scnewma! YAML truly is a cursed format. |
Some digging into this, and OPA even mentioned in this issue from a year ago: ghodss/yaml#77 |
Good find! After some more poking, I found that the Kubernetes project has their own fork of ghodss/yaml as well here: https://github.com/kubernetes-sigs/yaml. It looks like they weren't able to simply upgrade from go-yaml v2 to v3, though from a quick glance it's hard to tell if that's because of something Kubernetes specific vs changes to the library. |
Interesting. Thanks @scnewma! It'd be useful to try that out as an alternative to our current version. |
Forgot to add more details. I tried that and because that library has not updated to go-yaml v3 it still has the on/off bug 😞 . I believe the only option may be the fork that you mentioned in your first link. |
Thanks @scnewma! Sounds like it'd be worth investigating that option then 👍 |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
Hi,
|
You can force YAML to treat the key as a string by quoting it. Ex: "on":
foo: bar -> {
"on": {
"foo": "bar"
}
} |
Hi @jalseth |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue. |
Short description
When using a YAML file as a data input, object keys that are YAML keywords are not converted correctly to JSON. A common example is
on
which is commonly used in Github Actions YAML. When loaded as data, theon
object key is converted totrue
instead.opa version:
0.50.0
Steps To Reproduce
data.yaml
example.rego
Evaluate a basic OPA query to check if
on
is equal to"push"
:Expected behavior
Able to query for the
on
field and get data back.Additional context
This happens because
on
is converted totrue
in the key, as can be seen with this query:This happens with
off
keyword as well (it's converted tofalse
):data.yaml
The text was updated successfully, but these errors were encountered: