Added support to handle nested Pydantic types#3393
Merged
AdilFayyaz merged 7 commits intomasterfrom Feb 18, 2026
Merged
Conversation
|
Thank you for opening this pull request! 🙌 These tips will help get your PR across the finish line:
|
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
d01fd58 to
d529d5c
Compare
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
pingsutw
approved these changes
Feb 18, 2026
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.
Tracking issue
Duplicated from: flyteorg/flyte-sdk#640
Why are the changes needed?
To ensure the same behavior persists between v1 and v2
What changes were proposed in this pull request?
Fix
_get_element_type()in the type engine to correctly resolve nested and recursive Pydantic types that were previously flattened to strAdd $ref resolution so nested models or enums inside containers (List, Dict) are resolved via $defs lookup instead of defaulting to str
Rewrite anyOf handling to support $ref variants (e.g. Optional[Inner]), fixing KeyError: 'type' crashes
Add recursive array/object branches so nested containers (List[List[int]], Dict[str, Dict[str, int]]) resolve to their correct Python types
Handle null JSON schema type, returning NoneType instead of str
Add example demonstrating all nested Pydantic type patterns running as parallel Flyte tasks
Note: In v1, _handle_json_schema_property is called recursively for each variant inside an anyOf (e.g. Optional[Inner] produces {"anyOf": [{"$ref": "#/$defs/Inner"}, {"type": "null"}]}). When it recurses on the $ref variant {"$ref": "#/$defs/Inner"}, there is no "type" key, causing a KeyError: 'type'.
v1 iterates over all properties, so we added $ref resolution in
_handle_json_schema_propertybefore the "type" lookup to delegate to_get_element_type, which already knows how to resolve $ref paths.How was this patch tested?
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link