From 76d0f8d004c81d3542a51147041e61a392aecdeb Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Sun, 26 Apr 2026 05:23:00 -0700 Subject: [PATCH] fix(a2a): document the metadata-attach except-pass in a2a_executor (closes #1787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Code Quality bot flagged the empty `except (AttributeError, TypeError): pass` at workspace/a2a_executor.py:424 as a nit on PR #1783. The suppression IS intentional — `new_agent_text_message()` returns a plain string in MagicMock paths in tests where assignment to `.metadata` raises despite hasattr being true. This: - Adds a why-comment citing the test-mock motivation, commit dcbcf19 (the original guard), and issue #1787 so the next code-quality pass doesn't re-flag it. - Adds `logger.debug("metadata attach skipped (non-Message ...")` for observability — debug-level so production logs stay quiet but ops can flip the level if metadata loss is ever suspected. Behavior unchanged. 43 existing a2a_executor tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- workspace/a2a_executor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/workspace/a2a_executor.py b/workspace/a2a_executor.py index b550a350..69c56398 100644 --- a/workspace/a2a_executor.py +++ b/workspace/a2a_executor.py @@ -422,7 +422,14 @@ class LangGraphA2AExecutor(AgentExecutor): try: msg.metadata = {"tool_trace": tool_trace} except (AttributeError, TypeError): - pass + # `new_agent_text_message()` returns a plain string in + # MagicMock paths in tests, where assignment to + # .metadata raises despite hasattr being true (the + # mock has the attribute as a property). Suppression + # is intentional — production Message objects always + # accept the assignment. See #1787 + commit dcbcf19 + # for the original test-mock motivation. + logger.debug("metadata attach skipped (non-Message return from new_agent_text_message)") await event_queue.enqueue_event(msg) _result = final_text