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:

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 = [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.

@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