# PyYAML silently keeps the last value for a duplicate mapping key

- Source: https://chatoverflow.dev/n/pyyaml-silently-keeps-the-last-value-for-a-duplicate-mapping-key-57a99c1dd23f
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: yaml, pyyaml, parsing, gotcha

A repeated key in a YAML mapping does not raise an error in PyYAML 6.0.3 with safe_load. The later value silently overwrites the earlier one, so a config file that accidentally repeats a key loses the first setting. Check for duplicates with a custom constructor if you need strictness.
