-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 loading and serializing does not handle None properly #43694
Comments
PyYaml converts empty values to I am going to mark this as a bug, but I would highly recommend using file.managed if you and values to remain empty instead of having None specified. Thanks, |
Hi @gtmanfred it seems this can be addressed by https://stackoverflow.com/questions/37200150/can-i-dump-blank-instead-of-null-in-yaml-pyyaml https://stackoverflow.com/questions/30134110/how-can-i-output-blank-value-in-python-yaml-file |
Ok, so it is an easy solution to solve.
I am just not sure if it should be "solved" for everyone by default or not. It might make more sense to set it to The other problem is if we change this behavior, Then any files dumped from this module won't be readable by salts yaml loader. @saltstack/team-core does anyone have any suggestions here? Thanks, |
If it is loaded as empty from a YAML, it should remain empty in the end, and that is the case. One idea is to change the serializer behaviour by introducing per-format options. |
I have a similar problem.
to {'a': None, 'b': 'null', 'c': 'null\\nnull\\nnull'} This is appears when I do a Example:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
I think this is still an issue. |
@Ch3LL or @garethgreenaway Can you re-open this? |
Thank you for updating this issue. It is no longer marked as stale. |
@rallytime done. |
I have the same issue when using template:
pkg: ~ |
A tilde is a null value in YAML. Are you trying to get a literal tilde? If so you'll need to quote it. >>> import yaml
>>> yaml.safe_load('foo: ~')
{'foo': None}
>>> yaml.safe_load('foo: "~"')
{'foo': '~'}
>>> |
Hello @terminalmage, I want a Looks like I have an issue with my macros, I
Sorry for the noise, I should have missed something. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
Thank you for updating this issue. It is no longer marked as stale. |
Description of Issue/Question
I am using
import_yaml
to load a YAML file that has some keys with empty values (Ex.:key:
), then usefile.serialize
to write it to a YAML file again. But all keys that previously had no values, now have aNone
in place, which is a valid string, but not a valid YAML empty value.This is causing problems because the program that expects an empty or decimal value is getting a string instead.
Setup
Steps to Reproduce Issue
Can be verified using
state.show_sls
.Versions Report
The text was updated successfully, but these errors were encountered: