Structured variable replacement can break yaml files that have comments
Team
- [X] I've assigned a team label to this issue
Severity
One report with possibly no work around
Version
Reported in 2021.3.8275 and reproduced in 2022.3.1455
Latest Version
No response
What happened?
Performing structured variable replacements on yaml files that have comments can break yaml files. The issues discovered are:
- Comments and colons can swap places if the comment is on a new line.
- Empty lines are removed.
- Line indentations are sometimes altered. (Example in source report.)
Reproduction
For point 1 above, create a yaml file with this content:
output.elasticsearch:
# Comment.
hosts: ["something"]
Run structured configuration variables feature on this yaml file (output.elasticsearch:hosts variable)
output.elasticsearch
# Comment.
:
hosts: ["variable value"]
Error and Stacktrace
No response
More Information
Workaround
For point 1, move a single-line comment into the end of the first line, e.g.
output.elasticsearch: # Comment.
hosts: ["something"]
I've produced a reproduction here: https://octopus-operations.octopus.app/app#/Spaces-162/projects/yaml-replacement-issue/deployments/releases/0.0.20/deployments/Deployments-40372
Artifact (2.0.0) already created.
Important to note - most yaml files are going to have multi-line comments. Removing multi line comments is not a suitable workaround for many customers. The Multi-line comment issue breaks the yaml file. The rest of the issues are annoying but non-breaking.
More users running into this issue: https://octopus.zendesk.com/agent/tickets/101822
Hello,
I've just ran into this same problem and had to change comment placements (as suggested in the workaround above) to fix it.
It would be nice to have this fixed.
Fixed by: https://github.com/OctopusDeploy/Calamari/pull/1057
Release Note: Fixed the bug which breaks structured variable replacement for YAML files when comments are added at particular locations.