Fix flattened child unknown fields - #752
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #752 +/- ##
==========================================
+ Coverage 90.83% 90.94% +0.10%
==========================================
Files 13 13
Lines 2040 2340 +300
Branches 370 457 +87
==========================================
+ Hits 1853 2128 +275
- Misses 124 140 +16
- Partials 63 72 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When a flattened child has deny_unknown_fields=True, it should not see the parent's own fields as unknown input. Pass only the relevant flattened input to child deserializers, while still allowing flatten dict fields to collect extra keys in parent, child, and nested child classes.
AllanChain
force-pushed
the
fix/flatten-unknown
branch
from
May 31, 2026 08:36
1b30396 to
fb6def1
Compare
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.
Previously, when we have a flattened child class with
deny_unknown_fields=True, we will have a problem deserializing.Actual behavior:
Expected:
The fix strategy is passing only the relevant flattened input to child deserializers, achieved by knowing the exact keys expected by the flattened child. Special cases are flattened dict fields. If the parent has flattened dict fields whereas the flattened child does not, we will keep the unknown fields only visible by the parent. Otherwise, we will pass those to the child.
The changes are done by a coding agent, and I have reviewed the code by trying to understand the changes line by line. The changes are reasonable and readable.