YQ gives invalid/useless error description while processing an invalid yaml document.
version of yq:
$ yq -V
yq version 3.4.0
operating system: linux amd64, the yq binary was installed from github releases manually
Input Yaml
An invalid document:
aaa:
bbb: x
ccc: "["y":1]"
Command
So far we tried:
$ yq r test.yml aaa.bbb
and
$ yq w test.yml aaa.bbb test
Actual behavior
$ yq r test.yml aaa.bbb
Error: yaml: line 1: did not find expected key
$ yq w test.yml aaa.bbb test
Error: Error reading document at index 0, yaml: line 1: did not find expected key: yaml: line 1: did not find expected key
Usage:
yq write [yaml_file] [path_expression] [value] [flags]
Aliases:
write, w
Examples:
yq write things.yaml 'a.b.c' true
yq write things.yaml 'a.*.c' true
yq write things.yaml 'a.**' true
yq write things.yaml 'a.(child.subchild==co*).c' true
yq write things.yaml 'a.b.c' --tag '!!str' true # force 'true' to be interpreted as a string instead of bool
yq write things.yaml 'a.b.c' --tag '!!float' 3
yq write --inplace -- things.yaml 'a.b.c' '--cat' # need to use '--' to stop processing arguments as flags
yq w -i things.yaml 'a.b.c' cat
yq w -i -s update_script.yaml things.yaml
yq w things.yaml 'a.b.d[+]' foo # appends a new node to the 'd' array
yq w --doc 2 things.yaml 'a.b.d[+]' foo # updates the 3rd document of the yaml file
Flags:
--anchorName string anchor name
-d, --doc string process document index number (0 based, * for all documents) (default "0")
-f, --from string yaml file for updating yaml (as-is)
-h, --help help for write
-i, --inplace update the yaml file inplace
--makeAlias create an alias using the value as the anchor name
-s, --script string yaml script for updating yaml
--style string formatting style of the value: single, double, folded, flow, literal, tagged
-t, --tag string set yaml tag (e.g. !!int)
Global Flags:
-C, --colors print with colors
-I, --indent int sets indent level for output (default 2)
-P, --prettyPrint pretty print
-j, --tojson output as json. By default it prints a json document in one line, use the prettyPrint flag to print a formatted doc.
-v, --verbose verbose mode
Expected behavior
Possibly an error message with some line number indicating where the syntax error is? :thinking:
Additional context
This has some nice potential for wasting unaware user's time :+1::innocent:. This happened to my colleague. We get it that the document was incorrect, but yq didn't help us... :sob:
Yes, and please do not print the Usage sting if provided file has invalid content.
The Usage string should be only printed if a command arguments are invalid or missing.
Describe the bug
YQ gives invalid/useless error description while processing an invalid yaml document.
version of yq:
operating system: linux amd64, the yq binary was installed from github releases manually
Input Yaml
An invalid document:
Command
So far we tried:
and
Actual behavior
Expected behavior
Possibly an error message with some line number indicating where the syntax error is? :thinking:
Additional context
This has some nice potential for wasting unaware user's time :+1::innocent:. This happened to my colleague. We get it that the document was incorrect, but yq didn't help us... :sob:
Thanks for the great tool! :heart_eyes: