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

Dasel fails to parse a "null" yaml file #99

Closed
varac opened this issue Mar 4, 2021 · 5 comments · Fixed by #100
Closed

Dasel fails to parse a "null" yaml file #99

varac opened this issue Mar 4, 2021 · 5 comments · Fixed by #100
Labels
bug Something isn't working

Comments

@varac
Copy link

varac commented Mar 4, 2021

Describe the bug

Dasel fails to parse yaml file with null as the only content.

To Reproduce

  1. echo 'null' > /tmp/null.yml
  2. echo '---' > /tmp/null2.yml
  3. touch /tmp/null3.yml
  4. dasel -f /tmp/null.yml .
  5. repeat with other files
  6. All cmds fail with panic: reflect: call of reflect.Value.Interface on zero Value

Expected behavior

Dasel should not fail on valid (but empty) yaml.

Desktop (please complete the following information):

  • OS: Ubuntu 20.10
  • Version: v1.13.2

Additional context

yamllint, yq or ytt all don't fail on the same input files.

@varac varac added the bug Something isn't working label Mar 4, 2021
@TomWright
Copy link
Owner

Thank you for the clear examples. I'll take a look at this soon 👍

@TomWright
Copy link
Owner

Hi @varac,

I've made the changes required to get this working as expected. The fixes should also apply to other formats.

The one strange thing I've noticed is that empty YAML documents are marshal'd as JSON - this is down to the YAML package being used and I have raised an issue here: go-yaml/yaml#708

echo 'null' | go dasel -p yaml .
{}
echo '---' | go dasel -p yaml .
{}
echo '' | dasel -p yaml . 
{}

@varac
Copy link
Author

varac commented Mar 5, 2021

Thanks!

@TomWright
Copy link
Owner

It seems that {} is actually the correct representation: https://stackoverflow.com/questions/33510094/syntax-for-empty-dictionary-in-yaml

I'm happy to merge this in and get it released now.

@TomWright
Copy link
Owner

This is now released under v1.13.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants