Python: Fix input mutation in SerializationMixin.from_dict - #7901
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit intoAug 27, 2026
Conversation
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 27, 2026 08:22 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 27, 2026 08:22 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 27, 2026 08:22 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 27, 2026 08:22 — with
GitHub Actions
Active
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Aug 27, 2026
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
August 27, 2026 12:37
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
SerializationMixin.from_dict()can unexpectedly mutate nested dictionaries in the caller-provided input when dictionary-shaped dependencies are merged during deserialization.The method creates a shallow copy of the input dictionary, so nested dictionaries remain shared with the original input. The subsequent in-place
.update()operations therefore modify the caller's input.This can cause unexpected state to persist when the same serialized specification is reused across multiple
from_dict()calls. In particular, dependency data injected during one reconstruction can leak into subsequent reconstructions.This change fixes that behavior while preserving the existing dictionary dependency merge semantics and dependency precedence.
Description & Review Guide
What are the major changes?
.update()operations inSerializationMixin.from_dict()with non-mutating dictionary merges.from_dict()calls using the same input do not leak dependency state.What is the impact of these changes?
What do you want reviewers to focus on?
Related Issue
Fixes #7899
Contribution Checklist