Skip to content

fix(traverse_util): raise ValueError when flatten_dict separator conflicts with keys - #5593

Open
mayuriphad wants to merge 3 commits into
google:mainfrom
mayuriphad:fix-flatten-dict-sep
Open

mayuriphad wants to merge 3 commits into
google:mainfrom
mayuriphad:fix-flatten-dict-sep

Conversation

@mayuriphad

Copy link
Copy Markdown

Resolves #5554.

This PR modifies latten_dict to validate that keys are strings and do not contain the separator sep when sep is provided. This prevents silent data corruption when nested structures are restored using unflatten_dict, as well as opaque errors for non-string keys, replacing them with a clear ValueError.

A regression test and docstring update are included.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

flatten_dict with a separator cannot round-trip keys containing the separator, and raises an opaque error on non-string keys

1 participant