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

UnmarshalStrict() doesn't error on duplicate keys #284

Closed
aeijdenberg opened this issue Nov 3, 2017 · 3 comments
Closed

UnmarshalStrict() doesn't error on duplicate keys #284

aeijdenberg opened this issue Nov 3, 2017 · 3 comments

Comments

@aeijdenberg
Copy link

I spent yesterday afternoon tracking down a bug in our Concourse configuration whereby the root cause was a YAML file containing:

resource_types:
- name: foo
- name: bar

... hundreds of unrelated lines later ...

resource_types:
- name: baz

where the final resource_types effectively deleted the first.

I thought it would be within the spirit of what UnmarshalStrict() sounds like it should do, if it would return an error if a key is attempted to be set in a map (or struct) that already has value.

PR forthcoming for your consideration...

@aeijdenberg
Copy link
Author

Related: #154

@xunwu
Copy link

xunwu commented Dec 19, 2017

I am facing the same issue here, I think it should throw an error if duplicate keys are found, rather than silently replacing the value

rogpeppe added a commit to rogpeppe-contrib/yaml that referenced this issue Jan 7, 2018
This is similar to PR go-yaml#285 but somewhat more efficient
because it does not require a new map to be created
for every struct unmarshal.

Fixes go-yaml#284.
rogpeppe added a commit to rogpeppe-contrib/yaml that referenced this issue Jan 8, 2018
This is similar to PR go-yaml#285 but somewhat more efficient
because it does not require a new map to be created
for every struct unmarshal.

Fixes go-yaml#284.
@rogpeppe
Copy link
Contributor

rogpeppe commented Jan 8, 2018

Fixed by #307.

@rogpeppe rogpeppe closed this as completed Jan 8, 2018
djgilcrease pushed a commit to djgilcrease/yaml that referenced this issue Mar 14, 2018
This is similar to PR go-yaml#285 but somewhat more efficient
because it does not require a new map to be created
for every struct unmarshal.

Fixes go-yaml#284.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants