-
Notifications
You must be signed in to change notification settings - Fork 757
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
loadYamlContent(..)
converts unset properties (should be: null
) to empty strings (''
)
#14143
Comments
From what I can tell after a quick debug lookup is that the Yaml deserialization is handled by a third-party library called SharpYaml (https://github.com/xoofx/SharpYaml/tree/master) which happens to treat an empty value the same as ''. |
I just had a look at the YAML 1.2.2 specification:
Example 7.3: Completely Empty Flow Nodes seems to further clarify how empty node content should be resolved. I tried different YAML parsers (e.g. yq, pyyaml and Go's yaml/v2 package, which is based on LibYYAML) and it seems as if most parsers resolve empty node values to EDIT: |
Thanks for digging into this! |
Bicep version
Bicep CLI version 0.27.1 (4b41cb6d4b)
Describe the bug
While using a combination of
loadYamlContent()
in conjunction withunion()
andstring()
to construct an OpenTelemetry Collector configuration file (don't ask...!) I stumbled upon a rather interesting bug:yamlTest.bicep:
example.yaml:
To Reproduce
Steps to reproduce the behavior:
Create the two files as described above and use bicep to build the ARM template, e.g. by using the following shell script:
Additional context
Mitigation in my case was to explicitly set the properties to
null
, but it was kind of counter-intuitive and took me some time to figure out that Bicep'sloadYamlContent()
was doing something unexpected.The text was updated successfully, but these errors were encountered: