Skip to content
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

Missing quotes gives misleading error message #413

Open
dckc opened this issue May 23, 2020 · 5 comments
Open

Missing quotes gives misleading error message #413

dckc opened this issue May 23, 2020 · 5 comments
Labels
bug Issues describing a bug in go-toml.

Comments

@dckc
Copy link

dckc commented May 23, 2020

Describe the bug
The error message for missing quotes is misleading.

To Reproduce

  1. put something like timeout_broadcast_tx_commit = 20s in a .toml file
  2. start some utility that uses this library (such as cosmos-sdk)
  3. 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 cosmos/cosmos-sdk#5165

@AllenX2018
Copy link
Contributor

Thanks for reporting! I think it's a bug about the lexer when scanning integer type values

@dckc
Copy link
Author

dckc commented May 23, 2020

I wonder if it's specific to integer type values.

I got a similar error when quotes were missing from this line:

persistent_peers = 077c58e4b207d02bbbb1b68d6e7e1df08ce18a8a@178.62.245.23:26656,7d8550f6709e7ceaf170137fa6f950b50840185a@206.189.130.83:26656,25c93fb99654948f1f077b68ffa05feb85d909bb@138.197.185.203:26656,68e71ddd3801dc60c9a29afae28ea5bd0eddbe5c@134.209.176.58:26656,b0bdaf0e3eeb8078451ea274d16128f65610d682@138.68.63.241:26656,f6689f006fd3e1f27f1e7e83344f06198b47ee00@178.128.30.183:26656,30146727206eb81e796ccf837efa4b1f7235c221@165.227.33.200: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.

@pelletier pelletier added the bug Issues describing a bug in go-toml. label Aug 1, 2020
@bjanders
Copy link

bjanders commented May 6, 2021

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"

@pelletier
Copy link
Owner

Looks like that's still not great in v2: https://play.golang.org/p/9xauDfRSQI7

1| host = builddb
 |        ~~~~~~~ incomplete number


1| persistent_peers = 077c58e4b207d02bbbb1b68d6e7e1df08ce18a8a@178.62.245.23:26656,7d8550f6709e7ceaf170137fa6f950b50840185a@206.189.130.83:26656,25c93fb99654948f1f077b68ffa05feb85d909bb@138.197.185.203:26656,68e71ddd3801dc60c9a29afae28ea5bd0eddbe5c@134.209.176.58:26656,b0bdaf0e3eeb8078451ea274d16128f65610d682@138.68.63.241:26656,f6689f006fd3e1f27f1e7e83344f06198b47ee00@178.128.30.183:26656,30146727206eb81e796ccf837efa4b1f7235c221@165.227.33.200:26656
 |                     ~ expected newline but got U+0037 '7'

cc @vincentserpoul, on the topic of providing more meaningful errors.

@pelletier pelletier changed the title missing quotes gives misleading error message Missing quotes gives misleading error message Apr 28, 2022
@pelletier
Copy link
Owner

Good insight on #858: maybe we should consider passing the type of the target to provide a more accurate error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml.
Projects
None yet
Development

No branches or pull requests

4 participants