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

Issues parsing file with curly braces {{ }} #115

Closed
Lirt opened this issue Feb 16, 2021 · 3 comments
Closed

Issues parsing file with curly braces {{ }} #115

Lirt opened this issue Feb 16, 2021 · 3 comments

Comments

@Lirt
Copy link

Lirt commented Feb 16, 2021

Hello,

I'm trying to parse yaml file with double curly brace pair ({{ }}). If the file contains a curly brace pair used for example in helm or Go templating, it fails with error yq: Error running jq: TypeError: unhashable type: 'collections.OrderedDict'.

Here is example file you can try it on.

---
kind: test
metadata:
  name: test
spec:
  version: {{ .testVersion }}

yq version is 2.12.0.

@Lirt
Copy link
Author

Lirt commented Feb 16, 2021

It parses well when double curly braces are inside of string, so for example quoted like "{{ .testVersion }}", but also in case of yaml multi-line strings.

Which means this works for example.

---
kind: test
metadata:
  name: test
spec:
  version: |
    {{ .testVersion }}

@kislyuk
Copy link
Owner

kislyuk commented Feb 17, 2021

Hi, the unquoted inline scalar with inline double curly braces that you have in your example is not valid YAML, as far as I can tell. Different parsers produce different errors when trying to parse this, and yq could definitely do a better job of informing you that it's invalid, but you guessed correctly that the scalar needs to be quoted. Basically, unquoted { indicates the start of a flow mapping, and this scalar is not a valid flow mapping (and if interpreted as a mapping, wouldn't do what you intended anyway).

@kislyuk kislyuk closed this as completed Feb 17, 2021
@Lirt
Copy link
Author

Lirt commented Feb 17, 2021

Thank you, it makes sense.

Maybe it will help somebody to track the error message in the future.

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

No branches or pull requests

2 participants