Yao You 903efb0c6d
fix: fix occasional key error when mapping parent id (#3658)
This PR fixes an occasional `KeyError` when calling
`assign_and_map_hash_ids`.

- This happens when the input `elements` has duplicated element
instances or metadata.
- When there are duplications the logic to iterate through all elements
and map their parent ids will raise an error when an already mapped
parent id is up for mapping.
- The fix adds a logic to check if the parent id exists in
`old_to_new_mapping` and if it doesn't we skip mapping it

## test

This PR adds a unit test on this case and the test would fail without
the fix.
2024-09-24 16:39:11 +00:00
..