Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Structured variable replacement can break yaml files that have comments

Open KennethBates opened this issue 3 years ago • 2 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:

  1. Comments and colons can swap places if the comment is on a new line.
  2. Empty lines are removed.
  3. 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

Internal report

Workaround

For point 1, move a single-line comment into the end of the first line, e.g.

output.elasticsearch: # Comment.
  hosts: ["something"]

KennethBates avatar Jul 04 '22 05:07 KennethBates

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.

danefalvo avatar Jul 05 '22 13:07 danefalvo

More users running into this issue: https://octopus.zendesk.com/agent/tickets/101822

calverp avatar Nov 18 '22 07:11 calverp

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.

IAMDEH avatar Jan 27 '23 15:01 IAMDEH

Fixed by: https://github.com/OctopusDeploy/Calamari/pull/1057

ghost avatar Jun 13 '23 05:06 ghost

Release Note: Fixed the bug which breaks structured variable replacement for YAML files when comments are added at particular locations.

octoreleasebot avatar Jun 13 '23 05:06 octoreleasebot