Skip to content

A2A _serialize_value() corrupts JSON-native metadata types to strings #5183

Closed

Description

@YizukiAme

Bug Description

_serialize_value() in from_adk_event.py falls through to str() for JSON-native Python types (dict, list, bool, int, float), corrupting structured metadata values into their string representations during A2A event conversion.

Steps to Reproduce

from google.adk.a2a.converters.from_adk_event import _serialize_value

metadata = {"retry": True, "max_attempts": 3, "tags": ["alpha", "beta"]}
result = _serialize_value(metadata)
print(type(result), result)
# Actual: <class 'str'> "{'retry': True, 'max_attempts': 3, 'tags': ['alpha', 'beta']}"
# Expected: <class 'dict'> {'retry': True, 'max_attempts': 3, 'tags': ['alpha', 'beta']}

Expected Behavior

JSON-native types (dict, list, str, bool, int, float) should be preserved as-is since they are already valid JSON values, not converted to strings.

Actual Behavior

All non-Pydantic values that aren't None are passed through str(), which corrupts structured data into Python repr strings.

Activity

  1. added theissue type on Apr 7, 2026
  2. added
    core[Component] This issue is related to the core interface and implementation
    on Apr 7, 2026
  3. enjoykumawat commented on Apr 7, 2026

    @enjoykumawat
    Contributor

    I'd like to work on this. The fix is to pass through JSON-native types (dict, list, int, float, bool) as-is in _serialize_value() instead of stringifying them. Will submit a PR shortly.

  4. sanketpatil06 commented on Apr 10, 2026

    @sanketpatil06

    Hi @YizukiAme,
    Thank you for reporting this issue. I have reproduced it on my end and can confirm the metadata serialization behavior you are seeing.
    Additionally, thank you both, @YizukiAme and @enjoykumawat, for submitting pull requests. Our team is currently reviewing both PRs to determine the best approach for a fix.
    We really appreciate your contributions.

  5. enjoykumawat commented on Apr 10, 2026

    @enjoykumawat
    Contributor

    Thanks for the update @sanketpatil06! Happy to hear the team is reviewing both approaches.

    I'm happy to coordinate with @YizukiAme — if their implementation fits better with the codebase direction, feel free to close #5200. The goal is just to get the fix in.

    If there's anything specific you'd like me to adjust on my PR to make it easier to evaluate, just let me know.

  6. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on May 6, 2026
  7. added a commit that references this issue on Jun 18, 2026
    139c700
  8. added a commit that references this issue on Aug 11, 2026
    94b756e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationneeds review[Status] The PR/issue is awaiting review from the maintainer

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions