mikefarah / yq

yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
https://mikefarah.gitbook.io/yq/
MIT License
12.36k stars 602 forks source link

toml/yaml: did not find expected <document start> for certain files #2198

Closed mrchief closed 1 week ago

mrchief commented 1 week ago

Describe the bug Unless the toml file starts with a simple key-value, parsing fails.

Version of yq: 4.27.5 Operating system: linux (WSL) Installed via: wget

Input Yaml Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less) data1.toml:

[owner.contact]
name = "Tom Preston-Werner"
age = 36

data2.toml:

bug = "exists"
[owner.contact]
name = "Tom Preston-Werner"
age = 36

Command The command you ran:

yq -oy '.' data1.toml

Actual behavior

[owner.contact]
Error: bad file 'data1.toml': yaml: line 1: did not find expected <document start>

Expected behavior

[owner.contact] name = "Tom Preston-Werner" age = 36

Additional context Adding a dummy key to the file works.

yq -oy '.' data2.toml

outputs

|-
  bug = "exists"
  [owner.contact] name = "Tom Preston-Werner" age = 36
mikefarah commented 1 week ago

I have bumped the version of the toml parser, should now work in 4.44.5