Issues
Issues copied to clipboard
Structured variable replacement can break yaml files that have multi-line comments
Severity
Low
Version
Latest Version
I could reproduce the problem in the latest build
What happened?
Performing structured variable replacements on yaml files that have multiple comments on new lines a new record breaks yaml files.
Reproduction
Given the Source Yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: Test
labels:
app: web
mq:
#environment: "12345"
#appId: "12345"
user: "admin"
retry:
max: "3"
redelivery-attempts: "3"
#maxLocalMessages: "30"
auditQueue: "AuditService"
YAML after deployment: You can see the : was moved from mq: and placed below the commented lines.
apiVersion: apps/v1
kind: Deployment
metadata:
name: Test
labels:
app: web
mq
# environment: "12345"
# appId: "12345"
:
user: "Dan"
retry:
max: "3"
redelivery-attempts: "3"
# maxLocalMessages: "30"
auditQueue: "NewServiceName"
Error and Stacktrace
No response
More Information
This is an issue with older versions of YamlDotNet that is not present in the latest version (15.1.1 as of the time of writing this). When upgrading to the latest version of YamlDotNet another issue has been introduced (before this fix) where anchor tags now append a line break that is OS dependent. In tests we can see this adding CRLF line breaks to YAML files using plain line feeds. These tests are very specifically checking for line breaks. Considering we handle line feeds on a per-file basis by taking the most common line break, we're hesitant to include this change. It's unlikely to cause issues but given the broad use case and low impact of this issue we're hesitant to make this change. If you are impacted by this please let us know so we can re-prioritize this.
Workaround
Avoid multi line comments after a new record.