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

ReadYamlMapping does not handle keys with quotes correctly #357

Closed
windmueller opened this issue Jun 13, 2020 · 12 comments
Closed

ReadYamlMapping does not handle keys with quotes correctly #357

windmueller opened this issue Jun 13, 2020 · 12 comments

Comments

@windmueller
Copy link

My application uses eo-yaml for reading and writing YAML files. When upgrading from 4.3.0 to 4.3.1, my tests fail because the written file can not be parsed correctly.

The issue is a key containing a hyphen, like

output-directory: "/tmp"

Starting with eo-yaml 4.3.1, this is written as

"output-directory": "/tmp"

After parsing the file again, ReadYamlMapping returns null when calling yamlMapping.string("output-directory"). This is different to the behavior of RtYamlMapping which returns the correct string.

@amihaiemil
Copy link
Member

@stovocor Well, RtYamlMapping is used for building a YamlMapping, whereas ReadYamlMapping is the one used for reading one -- it's different logic inside them.

Have you tried the latest version, 5.0.1?
I remember I made a release at some point, solving a lot of issues regarding escaping/unescaping (but I can't remember which version was that).

@windmueller
Copy link
Author

Yes, the issue is still present with 5.0.1.

I created a small test case for the class. I could also add one for actually writing and reading a file.

@amihaiemil
Copy link
Member

@stovocor thanks. This test should be enough. I'll have a look and try to fix it asap.

@windmueller
Copy link
Author

Thank you very much for the quick response!

@amihaiemil
Copy link
Member

@stovocor I'm curious whether keys between quotes is correct in YAML or not?

Your tests started failing because since 4.3.1 eo-yaml also escaped the keys. Are escaped keys correct in YAML or not?

@windmueller
Copy link
Author

Are escaped keys correct in YAML or not?

At least they are uncommon. I would prefer for eo-yaml to write them without quotes. In that case my test is no longer valid.

@amihaiemil
Copy link
Member

@stovocor I also see they are used sometimes: https://stackoverflow.com/questions/14873227/escaping-colons-in-yaml/56718286

I think escaping should happen if the key contains special chars like - or :.
I'm working on the reading issue now.

@amihaiemil
Copy link
Member

amihaiemil commented Jun 13, 2020

@rultor release it please, tag is 5.0.2

@rultor
Copy link
Collaborator

rultor commented Jun 13, 2020

@rultor release it please, tag is 5.0.2

@amihaiemil OK, I will release it now. Please check the progress here

@rultor
Copy link
Collaborator

rultor commented Jun 13, 2020

@rultor release it please, tag is 5.0.2

@amihaiemil Done! FYI, the full log is here (took me 4min)

@amihaiemil
Copy link
Member

@stovocor 5.0.2 has just been released, it's already on Maven Central.
I'm closing this. Please feel free to open other Issues if you still have problems or find something else :)

@windmueller
Copy link
Author

All my tests pass again with 5.0.2. Thanks again!

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

No branches or pull requests

3 participants