One function

handle_metavalues in dynaconf/dynaconf

The author described this change as fix: clean up nested dynaconf_merge tokens when parent key is new (#1435). It counts as a record because the check below fails on the code as it stood at ec3bc0940 and passes on be353f739, with nothing else changed between the two runs.

Fix saved2026-07-29
Sharing licenceMIT · LICENSE
Change size+9 0

What the code was meant to do, written into the code itself as a docstring

Cleanup of MetaValues on new dict :param old: old values :param new: new values :param list_merge: Methods to use to merge lists - merge: default merge behavior, i.e. (unique) concatenation - shallow: replace the top-most level list of the nested structure - deep: iteratively traverse the nested structure and replace the element in the list at the level specified by the full_path

The change

7474 new[key] = object_merge(
7575 old.get(key), new[key], list_merge=list_merge
7676 )
77+ else:
78+ # No merge token on this level, but a nested level may still
79+ # carry one - it must be handled (and removed) as well. ref #1210
80+ nested_old = old.get(key)
81+ handle_metavalues(
82+ nested_old if isinstance(nested_old, dict) else {},
83+ new[key],
84+ list_merge=list_merge,
85+ )

The check that tells the two apart

failpass·tests/test_utils.py::test_nested_merge_token_is_cleaned_up_when_key_absent_in_old

Check file tests/test_utils.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itec3bc0940369d1f2281633940fcb86facf057382
Broken version dated2026-07-29
Moduledynaconf.utils.__init__
Units changedhandle_metavalues
Fingerprint00ca10bbf964cfff
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in dynaconf/dynaconf