Repository navigation
fix: guard against None converter results in RemoteA2aAgent - #5199
Closed
enjoykumawat wants to merge 2 commits into
Closed
enjoykumawat wants to merge 2 commits into
enjoykumawat wants to merge 2 commits into
Conversation
enjoykumawat
force-pushed
the
fix/remote-a2a-agent-none-check
branch
from
April 7, 2026 20:21
2d6d1ba to
abd66a3
Compare
Converter functions (convert_a2a_message_to_event, convert_a2a_task_to_event) return Optional[Event], but several handler paths in RemoteA2aAgent access attributes on the result without checking for None first. This causes AttributeError when a converter returns None (e.g., for empty messages or metadata-only events). Add `if not event: return None` guards at all four call sites in both the legacy and new-style response handlers. Github-Issue: google#5187
enjoykumawat
force-pushed
the
fix/remote-a2a-agent-none-check
branch
from
April 9, 2026 07:39
abd66a3 to
2d26d1d
Compare
Collaborator
|
Hi @enjoykumawat , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
Collaborator
|
Hi @DeanChensj , can you please review this. |
copybara-service Bot
pushed a commit
that referenced
this pull request
Jun 17, 2026
Merge #5199 ## Summary Fixes #5187 - **Problem:** `RemoteA2aAgent._handle_a2a_response` and `_handle_a2a_response_v2` crash with `AttributeError` when converter functions (`convert_a2a_task_to_event`, `convert_a2a_message_to_event`, or config-based converters) return `None`. The code immediately accesses `.custom_metadata` on the result without checking for `None`. - **Fix:** Added `None`-checks after every converter call in both handler methods. When a converter returns `None`, the handler now gracefully returns `None` (skip the event) instead of crashing. - **Tests:** Added `TestHandleNoneConverterResults` with three test cases covering the `None` return path for message converters and task converters in both v1 and v2 handlers. ## Test plan - [x] `python -m pytest tests/unittests/agents/test_remote_a2a_agent.py -v` -- all 98 tests pass - [x] New tests specifically verify that `_handle_a2a_response` returns `None` when `convert_a2a_message_to_event` returns `None` - [x] New tests verify that `_handle_a2a_response` returns `None` when `convert_a2a_task_to_event` returns `None` - [x] New tests verify that `_handle_a2a_response_v2` returns `None` when `a2a_message_converter` returns `None` Co-authored-by: George Weale <gweale@google.com> COPYBARA_INTEGRATE_REVIEW=#5199 from enjoykumawat:fix/remote-a2a-agent-none-check 8550233 PiperOrigin-RevId: 933978968
Collaborator
|
Thank you @enjoykumawat for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 23ff66e. Closing this PR as the changes are now in the main branch. |
FrigaZzz
pushed a commit
to FrigaZzz/adk-python
that referenced
this pull request
Aug 11, 2026
Merge google#5199 ## Summary Fixes google#5187 - **Problem:** `RemoteA2aAgent._handle_a2a_response` and `_handle_a2a_response_v2` crash with `AttributeError` when converter functions (`convert_a2a_task_to_event`, `convert_a2a_message_to_event`, or config-based converters) return `None`. The code immediately accesses `.custom_metadata` on the result without checking for `None`. - **Fix:** Added `None`-checks after every converter call in both handler methods. When a converter returns `None`, the handler now gracefully returns `None` (skip the event) instead of crashing. - **Tests:** Added `TestHandleNoneConverterResults` with three test cases covering the `None` return path for message converters and task converters in both v1 and v2 handlers. ## Test plan - [x] `python -m pytest tests/unittests/agents/test_remote_a2a_agent.py -v` -- all 98 tests pass - [x] New tests specifically verify that `_handle_a2a_response` returns `None` when `convert_a2a_message_to_event` returns `None` - [x] New tests verify that `_handle_a2a_response` returns `None` when `convert_a2a_task_to_event` returns `None` - [x] New tests verify that `_handle_a2a_response_v2` returns `None` when `a2a_message_converter` returns `None` Co-authored-by: George Weale <gweale@google.com> COPYBARA_INTEGRATE_REVIEW=google#5199 from enjoykumawat:fix/remote-a2a-agent-none-check 8550233 PiperOrigin-RevId: 933978968
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 #5187
RemoteA2aAgent._handle_a2a_responseand_handle_a2a_response_v2crash withAttributeErrorwhen converter functions (convert_a2a_task_to_event,convert_a2a_message_to_event, or config-based converters) returnNone. The code immediately accesses.custom_metadataon the result without checking forNone.None-checks after every converter call in both handler methods. When a converter returnsNone, the handler now gracefully returnsNone(skip the event) instead of crashing.TestHandleNoneConverterResultswith three test cases covering theNonereturn path for message converters and task converters in both v1 and v2 handlers.Test plan
python -m pytest tests/unittests/agents/test_remote_a2a_agent.py -v-- all 98 tests pass_handle_a2a_responsereturnsNonewhenconvert_a2a_message_to_eventreturnsNone_handle_a2a_responsereturnsNonewhenconvert_a2a_task_to_eventreturnsNone_handle_a2a_response_v2returnsNonewhena2a_message_converterreturnsNone