fix: guard against None converter results in RemoteA2aAgent handlers#5219
Open
giulio-leone wants to merge 1 commit intogoogle:mainfrom
Open
fix: guard against None converter results in RemoteA2aAgent handlers#5219giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Both _handle_a2a_response() and _handle_a2a_response_v2() dereference converter results (accessing event.content, event.custom_metadata) without guarding against None. Converters can legitimately return None for messages with no convertible parts, metadata-only events, or empty status updates. Add None guards after each converter call in both handlers: - Legacy handler: 3 guards (task-no-update, status-update-message, artifact-update paths) + 1 guard (A2AMessage path) - V2 handler: 1 guard (A2AMessage path; tuple path was already guarded) The fix returns None (skip event) which is consistent with the existing pattern in the v2 tuple branch and is properly handled by the caller in _run_async_impl via 'if not event: continue'. Fixes google#5187
285dbb3 to
22df0cc
Compare
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 —
AttributeError: 'NoneType' object has no attribute 'custom_metadata'crash inRemoteA2aAgentwhen converter functions returnNone.Root Cause
Both
_handle_a2a_response()(legacy) and_handle_a2a_response_v2()(v2) dereference converter results (e.g.event.custom_metadata,event.content) without checking forNone. The v2-default converters into_adk_event.pylegitimately returnNonevia_create_event()when there are no convertible parts and no event actions — this is by design for metadata-only updates, empty status changes, etc.Fix
Add
if not event: return Noneguards after each converter call site:_handle_a2a_response)_handle_a2a_response)_handle_a2a_response)_handle_a2a_response)_handle_a2a_response_v2)_handle_a2a_response_v2)Returning
Noneis consistent with the existing pattern in the v2 tuple branch and is properly handled by the caller in_run_async_implviaif not event: continue.Testing
TestRemoteA2aAgentNoneConverterResultscovering all converter paths in both handlers