Missing quotes gives misleading error message
Describe the bug The error message for missing quotes is misleading.
To Reproduce
- put something like
timeout_broadcast_tx_commit = 20sin a .toml file - start some utility that uses this library (such as cosmos-sdk)
ERROR: While parsing config: (136, 33): parsing error: keys cannot contain new lines
Expected behavior
ERROR: While parsing config: (136, 33): parsing error: value requires quotes or some such
Versions
- go-toml: current, I think: 16c9a8b
- go: go1.13.4.linux-amd64.tar.gz
- operating system: Linux
Additional context see also https://github.com/cosmos/cosmos-sdk/issues/5165
Thanks for reporting! I think it's a bug about the lexer when scanning integer type values
I wonder if it's specific to integer type values.
I got a similar error when quotes were missing from this line:
persistent_peers = [email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656
I'm not sure if the error message was the same. At some point while I was working on this, the error message was ERROR: While parsing config: invalid base.
But definitely in both cases, the solution was to add ""s around the value.
It's not specific to integer types. I had:
host = builddb
and got the "keys cannot contain new line" error. This was corrected by correcting my config:
host = "builddb"
Looks like that's still not great in v2: https://play.golang.org/p/9xauDfRSQI7
1| host = builddb
| ~~~~~~~ incomplete number
1| persistent_peers = [email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656
| ~ expected newline but got U+0037 '7'
cc @vincentserpoul, on the topic of providing more meaningful errors.
Good insight on #858: maybe we should consider passing the type of the target to provide a more accurate error.