-
-
Notifications
You must be signed in to change notification settings - Fork 748
Open
Description
Describe the bug
yq is producing invalid yaml removing all items from a list with an inline comment on the list key
Version of yq: yq (https://github.com/mikefarah/yq/) version v4.50.1
Operating system: linux -> Ubuntu 22.04.5 LTS
Installed via: apt
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
test.yaml:
testList: # A comment
- name: test1
value: 123
- name: test2
value: 456Command
The command you ran:
yq 'del(.testList[])' test.yaml
Actual behaviour
testList: # A comment
[]which is invalid:
$ yq 'del(.testList[])' test.yaml | yq .
Error: bad file '-': yaml: line 2: could not find expected ':'Expected behaviour
Valid yaml for the empty list.
I'd have thought the following would be best:
testList: [] # A commentReactions are currently unavailable