Commit 23ff66e
fix: guard against None converter results in RemoteA2aAgent
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: 9339789681 parent 30493ba commit 23ff66e
2 files changed
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
| 537 | + | |
536 | 538 | | |
537 | 539 | | |
538 | 540 | | |
| |||
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
| 564 | + | |
| 565 | + | |
562 | 566 | | |
563 | 567 | | |
564 | 568 | | |
| |||
571 | 575 | | |
572 | 576 | | |
573 | 577 | | |
| 578 | + | |
| 579 | + | |
574 | 580 | | |
575 | 581 | | |
576 | 582 | | |
| |||
641 | 647 | | |
642 | 648 | | |
643 | 649 | | |
| 650 | + | |
| 651 | + | |
644 | 652 | | |
645 | 653 | | |
646 | 654 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
910 | 910 | | |
911 | 911 | | |
912 | 912 | | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
913 | 936 | | |
914 | 937 | | |
915 | 938 | | |
| |||
1925 | 1948 | | |
1926 | 1949 | | |
1927 | 1950 | | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
1928 | 1972 | | |
1929 | 1973 | | |
1930 | 1974 | | |
| |||
0 commit comments