fix: preserve JSON-native types in A2A _serialize_value()#5200
Open
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
Open
fix: preserve JSON-native types in A2A _serialize_value()#5200enjoykumawat wants to merge 1 commit intogoogle:mainfrom
enjoykumawat wants to merge 1 commit intogoogle:mainfrom
Conversation
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.
Summary
Fixes #5183
_serialize_value()infrom_adk_event.pywas callingstr()on all non-Pydantic values, which corrupted JSON-native metadata types (dict,list,int,float,bool) by converting them to string representations.Before:
{"count": 42}became{"count": "42"},{"tags": ["a","b"]}became{"tags": "['a', 'b']"}After: JSON-native types (
dict,list,int,float,bool,str) are passed through as-is. Only non-JSON-serializable types (e.g.,datetime) are stringified.Changes
src/google/adk/a2a/converters/from_adk_event.py: Addedisinstancecheck for JSON-native types before thestr()fallback in_serialize_value()tests/unittests/a2a/converters/test_from_adk.py: AddedTestSerializeValueclass with tests fordict,list,int,float,bool,str,None, and non-JSON type handlingTest plan
pytest tests/unittests/a2a/converters/test_from_adk.py— 12 passed)datetime) are still stringified