Repository navigation
fix(serialization): preserve validation error messages when deserializing invalid components - #270
Open
fede-kamel wants to merge 1 commit into
Open
fede-kamel wants to merge 1 commit into
fede-kamel wants to merge 1 commit into
Conversation
…zing invalid components When a component failed validation during Component.from_dict, from_json or from_yaml, PydanticComponentDeserializationPlugin.deserialize rebuilt the ValidationError from the collected error type and location only. Pydantic error types such as value_error, which is what every @model_validator_with_error_accumulation validator raises, cannot be rebuilt without the context of the original error, so the deserializer crashed with "TypeError: ValueError: 'error' required in context" and the real message, for instance the end node without incoming control flow edge, was lost. The rebuilt line errors now wrap the original type and message in a PydanticCustomError, which keeps the error type and the message for every error type. The partial construction path (build_from_partial_config, get_validation_errors) is unchanged. Fixes oracle#269.
fede-kamel
force-pushed
the
fix/deserializer-validation-errors
branch
from
October 9, 2026 19:16
3e73dd2 to
6107693
Compare
This branch has not been deployed
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.
Fixes #269.
Root cause
PydanticComponentDeserializationPlugin.deserializecollects the validation errors of a component and rebuilds aValidationErrorfromInitErrorDetails(type=e.type, loc=e.loc, input=()). pydantic cannot render error types such asvalue_error, which is what every@model_validator_with_error_accumulationvalidator raises, from the type alone: they need the context of the original error.ValidationError.from_exception_datatherefore raisedTypeError: ValueError: 'error' required in contextand the real message (the unreachable end node, the input missing from the prompt, ...) was lost for everyfrom_dict,from_jsonandfrom_yamlcall on an invalid component.Changes
serialization/pydanticdeserializationplugin.py: wrap the original error type and message in aPydanticCustomErrorwhen rebuilding the line errors. This preserves both for every error type without needing the original context. The partial-construction path (from_partial_dict, which returns the collected errors) is unchanged.tests/serialization/test_serialization.py: regression tests covering aFlowwith an unreachableEndNodethroughComponent.from_dict,from_json,from_yamlandAgentSpecDeserializer.from_dict, and anAgentdeclaring an input that is not in its prompt. They assert theValidationErrorcarries the original message and thevalue_errortype. All fail onmainwith theTypeError, pass with the fix.Verification
SKIP_LLM_TESTS=1 pytest tests --ignore=tests/adapters --ignore=tests/evaluation: 912 passed, 407 skipped (Python 3.13).