-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid trailing UTF-8 octet #396
Comments
i narrowed down the problem, trustDomainAliases has non-utf character,
EDIT:
|
I have the same problem with accentuated char anywhere in the yaml document, even if only in comments. exemple.yml# french char w/ accent: à
foo: bar This simple write command crash because of the accentuated character. It runs fine without it. yq w -i exemple.yml "a.b" "c" Here is the full stacktrace $ yq w -i exemple.yml "a.b" "c"
panic: runtime error: index out of range [26] with length 26 [recovered]
panic: runtime error: index out of range [26] with length 26
goroutine 1 [running]:
gopkg.in/yaml%2ev3.handleErr(0xc0000f9920)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/yaml.go:276 +0x9c
panic(0x559908143bc0, 0xc000018a80)
/usr/lib/go-1.13/src/runtime/panic.go:679 +0x1b6
gopkg.in/yaml%2ev3.write(0xc0000ba700, 0xc000018a60, 0x1a, 0x20, 0xc0000f7d48, 0x1)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:93 +0x20b
gopkg.in/yaml%2ev3.yaml_emitter_write_comment(0xc0000ba700, 0xc000018a60, 0x1a, 0x20, 0xc00001ed20)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:1978 +0xcd
gopkg.in/yaml%2ev3.yaml_emitter_process_head_comment(0xc0000ba700, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:1111 +0x86
gopkg.in/yaml%2ev3.yaml_emitter_emit_block_mapping_key(0xc0000ba700, 0xc0000e2330, 0x1, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:775 +0x92
gopkg.in/yaml%2ev3.yaml_emitter_state_machine(0xc0000ba700, 0xc0000e2330, 0x1)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:297 +0x344
gopkg.in/yaml%2ev3.yaml_emitter_emit(0xc0000ba700, 0xc0000ba940, 0xc00001ed18)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/emitterc.go:153 +0x149
gopkg.in/yaml%2ev3.(*encoder).emit(0xc0000ba700)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:81 +0x3b
gopkg.in/yaml%2ev3.(*encoder).emitScalar(0xc0000ba700, 0x5599082bd3c1, 0x1, 0x0, 0x0, 0x0, 0x0, 0xc000032f02, 0x5599082e7128, 0x0, ...)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:402 +0x30e
gopkg.in/yaml%2ev3.(*encoder).node(0xc0000ba700, 0xc00009fe00, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:544 +0x1321
gopkg.in/yaml%2ev3.(*encoder).node(0xc0000ba700, 0xc00009fc20, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:493 +0xae7
gopkg.in/yaml%2ev3.(*encoder).node(0xc0000ba700, 0xc00009fae0, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:448 +0x21f
gopkg.in/yaml%2ev3.(*encoder).nodev(0xc0000ba700, 0x559908132fe0, 0xc00009fae0, 0x16)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:406 +0x7b
gopkg.in/yaml%2ev3.(*encoder).marshalDoc(0xc0000ba700, 0x0, 0x0, 0x559908132fe0, 0xc00009fae0, 0x16)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/encode.go:101 +0x22a
gopkg.in/yaml%2ev3.(*Encoder).Encode(0xc0000100c8, 0x559908132fe0, 0xc00009fae0, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/vendor/gopkg.in/yaml.v3/yaml.go:251 +0x100
github.com/mikefarah/yq/v3/pkg/yqlib.(*yamlEncoder).Encode(0xc0000100d0, 0xc00009fae0, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/pkg/yqlib/encoder.go:28 +0x46
github.com/mikefarah/yq/v3/cmd.mapYamlDecoder.func1(0xc000032a40, 0xc000032a40, 0x600)
/build/yq-1drM7d/yq-3.1/cmd/utils.go:249 +0x27b
github.com/mikefarah/yq/v3/cmd.readStream(0x7ffe54cdb8a7, 0xb, 0xc00000e5c0, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/cmd/utils.go:457 +0x255
github.com/mikefarah/yq/v3/cmd.readAndUpdate(0x5599081634e0, 0xc000010018, 0x7ffe54cdb8a7, 0xb, 0xc00008f3b0, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/cmd/utils.go:337 +0x25e
github.com/mikefarah/yq/v3/cmd.updateDoc(0x7ffe54cdb8a7, 0xb, 0xc00008f380, 0x1, 0x1, 0x5599081634e0, 0xc000010018, 0x1, 0x1)
/build/yq-1drM7d/yq-3.1/cmd/utils.go:296 +0xd8
github.com/mikefarah/yq/v3/cmd.writeProperty(0xc0000af400, 0xc00006e500, 0x3, 0x4, 0x0, 0x0)
/build/yq-1drM7d/yq-3.1/cmd/write.go:57 +0x126
github.com/spf13/cobra.(*Command).execute(0xc0000af400, 0xc00006e400, 0x4, 0x4, 0xc0000af400, 0xc00006e400)
/build/yq-1drM7d/yq-3.1/vendor/github.com/spf13/cobra/command.go:826 +0x462
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000aea00, 0x2, 0xc00008f170, 0xc0000221d8)
/build/yq-1drM7d/yq-3.1/vendor/github.com/spf13/cobra/command.go:914 +0x2fd
github.com/spf13/cobra.(*Command).Execute(...)
/build/yq-1drM7d/yq-3.1/vendor/github.com/spf13/cobra/command.go:864
main.main()
/build/yq-1drM7d/yq-3.1/_build/src/github.com/mikefarah/yq/yq.go:13 +0x62 |
@infa-ddeore : I used the #!/bin/bash
file_paths=$(grep -lr -i [àâéèêëîôùûç] .)
while IFS=' ' read -ra path; do
buffer=$(mktemp -t ${path##*/}.XXXXXX)
unaccent UTF-8 < ${path} > ${buffer}
mv -f ${buffer} ${path}
done <<< "${file_paths}" However, one of our config file holds a PGP public key with accentuated char in the key's comment. I can't alter the key's comment without altering it's hash... |
Yeah this is a problem in the underlying yaml parser, there is an issue raised there: go-yaml/yaml#578 :( |
@mikefarah on macos ... $ file -I draft.yaml
draft.yaml: text/plain; charset=utf-8
$ yq w draft.yaml 'a.b.c.' blah | file -I -
/dev/stdin: text/plain; charset=iso-8859-1 is the |
Describe the bug
Error after appending result to another yaml
Input Yaml
Giving full file as the issue is reproducible with it
data1.yml:
Command
The command you ran:
Actual behavior
Should not get the error, manually copying the output to other file instead of redirection doesn't have any issue
Expected behavior
There shouldn't be UTF error with io redirection to a file
The text was updated successfully, but these errors were encountered: