You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_clean_empty in src/a2a/utils/helpers.py is documented to "recursively remove empty strings, lists and dicts". The base case correctly targets only '', [], {}, but the dict and list filters use truthiness (if v) which also drops 0, False, and 0.0:
This affects canonicalize_agent_card() (the only caller), which produces canonical JSON for signature verification (RFC 8785). An AgentCard with e.g. AgentCapabilities(streaming=False) would have the field stripped after surviving model_dump(exclude_none=True), losing the distinction between "explicitly disabled" and "unspecified".
If this behavior is intentional, I may be missing some context — in that case, clarifying the docstring and base case to better reflect the current filtering semantics could help avoid confusion.
If it’s considered a bug, I’d be glad to open a PR with the proposed change and add regression tests as needed.
Hi @cchinchilla-dev , thanks for bringing this up. _clean_empty function is designed to eliminate empty strings, lists and dictionaries.
Your solution if v is not None would preserve values like 0, False, 0.0 ,however it will deviate from the function purpose of removing empty strings, lists and dictionaries.
Please go ahead a propose a PR for this but your solution needs to be adapted to the above case.
Thanks for the review! You're right — if v is not None would let [] and {} slip through since they never reach the base case. I'll open a PR shortly using explicit sentinel checks instead, with tests covering both sides.
Activity
rohityan commentedon Feb 19, 2026
Hi @cchinchilla-dev , thanks for bringing this up.
_clean_emptyfunction is designed to eliminate empty strings, lists and dictionaries.Your solution
if v is not Nonewould preserve values like0, False, 0.0,however it will deviate from the function purpose of removing empty strings, lists and dictionaries.Please go ahead a propose a PR for this but your solution needs to be adapted to the above case.
cchinchilla-dev commentedon Feb 19, 2026
Hi @ryanaiagent,
Thanks for the review! You're right —
if v is not Nonewould let[]and{}slip through since they never reach the base case. I'll open a PR shortly using explicit sentinel checks instead, with tests covering both sides.fix(core): preserve legitimate falsy values in _clean_empty (a2aproje…