acoustic-carpenter-78188
06/23/2026, 5:05 PMdefault_factory fields:
TypeError: non-default argument '<field>' follows default argument
Pydantic omits the default key from the JSON schema for default_factory fields, so they were handed to make_dataclass without a default. Whenever a defaulted field happened to precede one in the (hash-randomized) schema order, make_dataclass raised intermittently. Earlier SDKs instead dropped these fields silently (lossy reconstruction).
Regression from #1171, which stopped dropping non-required fields but left default_factory fields without a default on the dataclass path. The tagged Pydantic path (create_model, no field-ordering constraint) was already
correct; this only affects the untagged path that older, pre-tagging producers' outputs take.
Fix
Give every non-required field a default during reconstruction, choosing a faithful one by shape:
• list → [], dict → {}
• nested model (no-arg constructible) → a constructed instance (recursive)
• everything else → Optional[...] = None
Fixes the crash and restores full-fidelity reconstruction (no dropped fields) on the untagged path.
Test plan
• Added regression tests covering all field orderings, all-optional schemas, collection defaults, and nested models (constructed instance + fallback to None when the nested model has a required field).
• Confirmed the new tests fail on the pre-fix code and pass after.
• Full type-engine suite passes.
Fixes https://linear.app/unionai/issue/ENG26-756/make-dataclass-ordering-crash-for-untagged-pydantic-struct-outputs, https://linear.app/unionai/issue/ENG26-791/tagged-pydantic-path-reconstructs-default-factory-fields-as-required
🤖 Generated with Claude Code
flyteorg/flyte-sdkacoustic-carpenter-78188
06/25/2026, 4:23 PM