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

Issue parsing duplicate keys #666

Closed
moorereason opened this issue Nov 10, 2021 · 1 comment
Closed

Issue parsing duplicate keys #666

moorereason opened this issue Nov 10, 2021 · 1 comment
Labels
bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version.
Milestone

Comments

@moorereason
Copy link
Contributor

Describe the bug
Two inputs with duplicate keys give invalid or odd results:

Given a={}\na={}, gotoml-test-decoder returns:

{
  "a": {}
}

Given a=1\na=2, gotoml-test-decoder returns:

Error decoding TOML: toml: expected a to be a table, not a value

To Reproduce
https://play.golang.org/p/Z3TgOrkhs5B

toml.Unmarshal([]byte("a={}\na={}"), &v)

https://play.golang.org/p/J59RodyIGaf

toml.Unmarshal([]byte("a=1\na=2"), &v)

Expected behavior
In both cases, I expected to see an error about duplicate keys in the "root" table.

While we get an error with the second input, the error is confusing.

Versions

  • go-toml: 2dbd29a
  • go version go1.17.1 linux/amd64

Additional context
Found while doing differential fuzzing against BurnstSushi.

@pelletier pelletier added the bug Issues describing a bug in go-toml. label Nov 10, 2021
@pelletier pelletier added this to the v2.0.0-beta.5 milestone Nov 10, 2021
@pelletier pelletier added the v2 Issues impacting the v2 major version. label Nov 10, 2021
@pelletier
Copy link
Owner

Should be fixed by 4dff8ea. Filed #668 to provide better errors for duplicates tracking.

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. v2 Issues impacting the v2 major version.
Projects
None yet
Development

No branches or pull requests

2 participants