question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate keys are not handled properly

See original GitHub issue

YAML spec in version 1.2 says that in a valid YAML file, mapping keys are unique.

This is not the case in pyyaml, as can be seen by loading this sample file:

a:
  - b
  - c

a:
  q: a
  q: b

The correct result from loading this file is an error. pyyaml instead naively overwrites results with the last key, resulting in this dict: {'a': {'q': 'b'}}.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:36
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
alexchandelcommented, Jun 24, 2020

PyYAML should reject duplicate keys per the YAML spec. These are silent errors in users’ code. Do what ruamel.yaml does, and add a yaml.allow_duplicate_keys = True property for those who want to opt-in.

5reactions
perlpunkcommented, Jan 7, 2020

The YAML 1.1 spec also says that keys should be unique: https://yaml.org/spec/1.1/#id861060

The content of a mapping node is an unordered set of key: value node pairs, with the restriction that each of the keys is unique

Read more comments on GitHub >

github_iconTop Results From Across the Web

Will A Locksmith Copy A “Do Not Duplicate” Key?
Yet the fact remains that keys stamped with “Do Not Duplicate” are no more secure than keys without it. According to the Associated...
Read more >
All About "Do Not Duplicate" Keys - Door Locks Direct
Learn all about “do not duplicate” keys and what you should do if you've lost your keys at Door Locks Direct. Call us...
Read more >
Proper layer to handle duplicate keys
My understanding to handle duplicate keys should be handled by the database. For example, When a user wants to add new entity with...
Read more >
Do Not Duplicate Keys Debunked - Industrial Lock and Security
If you're a business owner, having these signs engraved on your keys won't guarantee lock security. The best way to secure your company...
Read more >
Implementing Binary Search Tree To Handle Duplicate Keys ...
One important problem with our implementation of insert is that duplicate keys are not handled properly. As our tree is implemented a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found