-
-
Notifications
You must be signed in to change notification settings - Fork 745
Description
Describe the bug
When modifying a YAML file using yq eval with in-place editing, multiline strings that contain trailing spaces are incorrectly converted to single-line strings.
Version of yq: yq (https://github.com/mikefarah/yq/) version v4.45.1
Operating system: macOS
Installed via: Homebrew
Input YAML
orig.yaml:
hello: world
annotations:
zero: asdf
one: |
This is a multi-line string.
It has multiple lines.
two: |
one more line
Line with spaces at the end
Normal line
three:
four: fiveCommand
yq eval '.annotations.one = ""' -i orig.yamlActual behavior
The output orig.yaml is modified as follows:
hello: world
annotations:
zero: asdf
one: ""
two: "one more line\nLine with spaces at the end \nNormal line\n"
three:
four: fiveThe annotations.two field, which originally used the block scalar |, is converted into a single-line string with explicit \n characters.
Expected behavior
Only annotations.one should be modified, while annotations.two should retain its original formatting:
hello: world
annotations:
zero: asdf
one: ""
two: |
one more line
Line with spaces at the end
Normal line
three:
four: fiveAdditional context
This issue seems to occur when a multiline string contains trailing spaces. The expected behavior is that unmodified fields retain their original block scalar formatting.