One function

find_the_correct_casing in dynaconf/dynaconf

The author described this change as fix: skip non-str keys when resolving key casing (#1446). It counts as a record because the checks below fail on the code as it stood at 0e26bd6d6 and pass on 282f0935f, with nothing else changed between the two runs.

Fix saved2026-08-05
Sharing licenceMIT · LICENSE
Change size+2 2

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

Given a key, find the proper casing in data. Return 'None' for non-str key types. Arguments: key {str} -- A key to be searched in data data {dict} -- A dict to be searched Returns: str -- The proper casing of the key in data

The change

33 ) -> str | None:
44 """Given a key, find the proper casing in data.
55
6- Return 'None' for non-str key types.
6+ Non-str keys in data are skipped.
77
88 Arguments:
99 key {str} -- A key to be searched in data
1616 return key
1717 for k in data_keys:
1818 if not isinstance(k, str):
19- return None
19+ continue
2020 if k.lower() == key.lower():
2121 return k
2222 if k.replace(" ", "_").lower() == key.lower():

The check that tells the two apart

failpass·tests/test_utils.py::test_find_the_correct_casing_skips_non_str_keys
failpass·tests/test_utils.py::test_merge_existing_dict_with_non_str_keys

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 it0e26bd6d69fe22ddc17f48fff5b2046d4403b3fa
Broken version dated2026-08-03
Moduledynaconf.utils.__init__
Units changedfind_the_correct_casing
Fingerprint307b34aea81a6236
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