fix: preserve JSON-native types in A2A metadata serialization#5181
Open
YizukiAme wants to merge 1 commit intogoogle:mainfrom
Open
fix: preserve JSON-native types in A2A metadata serialization#5181YizukiAme wants to merge 1 commit intogoogle:mainfrom
YizukiAme wants to merge 1 commit intogoogle:mainfrom
Conversation
Signed-off-by: Yizuki_Ame <yinzimike@gmail.com>
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 #5183
Problem
_serialize_value()infrom_adk_event.pyfalls through tostr()for JSON-native Python types (dict,list,bool,int,float), corrupting structured metadata values into their string representations during A2A event conversion.For example, a
custom_metadatadict like{"retry": True, "max_attempts": 3}gets serialized as"{'retry': True, 'max_attempts': 3}"— a Python repr string instead of a proper JSON object.Fix
dict,list,str,bool,int,floatare now returned as-is since they are already valid JSON values.__dict__), normalize viajson.loads(json.dumps(value))before falling back tostr().custom_metadataround-trip to ensure values are not corrupted to strings.Logs After Fix
Testing Plan
All 143 A2A converter tests pass. The new
test_custom_metadata_structured_roundtriptest verifies thatdict,list,bool,int, andfloatvalues survive the_serialize_value()→ metadata round-trip without being corrupted to strings.