fix(serialization): surface collected deserialization errors instead of masking them - #27
Open
spichen wants to merge 1 commit into
Open
fix(serialization): surface collected deserialization errors instead of masking them#27spichen wants to merge 1 commit into
spichen wants to merge 1 commit into
Conversation
…of masking them
PydanticComponentDeserializationPlugin.deserialize rebuilt the collected
validation errors into pydantic_core InitErrorDetails carrying only
(type, loc). from_exception_data then re-derives each builtin type's
required ctx (value_error needs {"error": <exc>}, gt needs gt, ...), so a
collected value_error -- any component model_validator that raises
ValueError -- made from_exception_data itself raise
TypeError("'error' required in context"), hiding the real cause. (Seen in
the field as a swarm-as-flow-node AgentNode port mismatch surfacing as the
opaque "TypeError: ValueError: 'error' required in context".)
Rebuild each collected error with a PydanticCustomError that carries its
message directly (rendered verbatim, no ctx and no template interpolation),
so any error type reconstructs without the per-type ctx dance and both the
original type and message are preserved.
spichen
force-pushed
the
fix/surface-deserialization-errors
branch
from
July 13, 2026 19:16
6f083af to
04a03da
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.
Problem
PydanticComponentDeserializationPlugin.deserializerebuilds the collected validation errors intopydantic_core.InitErrorDetailscarrying only(type, loc):ValidationError.from_exception_datathen re-derives each builtin type's required ctx (value_errorneeds{"error": <exc>},gtneedsgt, …). With none supplied, a collectedvalue_error— any componentmodel_validatorthat raisesValueError— makesfrom_exception_dataitself raise:…which masks the real cause. Seen in the field as a Swarm-used-as-a-Flow-node
AgentNodeport mismatch (ValueError("... expected a property titled 'evidence_status' ...")) surfacing only as the opaqueTypeError: ValueError: 'error' required in context.Fix
Rebuild each collected error with a
PydanticCustomError(e.type, e.msg), which carries the message directly — rendered verbatim (no ctx, no template interpolation). This reconstructs an error of any type without the per-type ctx dance, and preserves both the originaltypeandmsg.Notably simpler than special-casing
value_error/ctx: no branch on type, no message munging, no double-prefixing.Tests
tests/serialization/test_deserialization_error_surfacing.py:value_errorre-raises as aValidationError(notTypeError) with its message verbatim (no added/doubledValue error,prefix);typeis preserved (amissingstaysmissing, not flattened tovalue_error);{/}(JSON) survive verbatim (not treated as a format template);error_count == 2.Full
tests/serialization/suite: 303 passed (the 4 pre-existingtest_llm_node.pydefault_llm_configfixture errors are unrelated to this change).