[Bug]: A2ACardResolver.get_agent_card raises UnicodeDecodeError and RecursionError instead of AgentCardResolutionError
維護者通常 2 天內回覆
@rohityan 已經在處理了。
開始於 2026年11月16日。
評估
這個 Issue 還沒有評估資料。
描述
What happened?
A2ACardResolver.get_agent_card() documents AgentCardResolutionError when "the response body cannot be decoded as JSON", and #1307 made the parser side keep that promise. Two bodies still escape as builtins, because the except clauses catch only json.JSONDecodeError: a card served as Latin-1 raises UnicodeDecodeError, and a deeply nested body raises RecursionError. A caller that handles AgentCardResolutionError around card discovery gets an unhandled exception from a remote agent's bad card.
Reproduced on caab6a2 (main), Python 3.10.21, httpx 0.28.1:
import asyncio
import httpx
from a2a.client import A2ACardResolver, AgentCardResolutionError
BODIES = {
'latin-1 body': '{"name": "Café"}'.encode('latin-1'),
'deep nesting': b'{"name": ' + b'[' * 100_000 + b']' * 100_000 + b'}',
}
async def main():
for label, body in BODIES.items():
transport = httpx.MockTransport(lambda _, b=body: httpx.Response(200, content=b))
async with httpx.AsyncClient(transport=transport) as client:
try:
await A2ACardResolver(client, 'http://agent').get_agent_card()
except AgentCardResolutionError as e:
print(label, '-> AgentCardResolutionError')
except Exception as e:
print(label, '->', type(e).__name__, e)
asyncio.run(main())
Expected: both lines print AgentCardResolutionError, the same as a body of [] does today.
Listing UnicodeDecodeError and RecursionError beside json.JSONDecodeError would cover it. A bare ValueError would also swallow one raised by a caller's signature_verifier, which runs in the same try. I only checked the 1.0 resolver, not the v0.3 compat path. Happy to open the pull request with a MockTransport test for each body if that fix works for you.
Relevant log output
$ python repro.py
latin-1 body -> UnicodeDecodeError 'utf-8' codec can't decode byte 0xe9 in position 13: invalid continuation byte
deep nesting -> RecursionError maximum recursion depth exceeded while decoding a JSON array from a unicode string
Code of Conduct
- I agree to follow this project's Code of Conduct
- 主要語言
- Python
- 星號
- 2.2k
- 分支
- 540
- 平均合併
- 2 天 10 小時
- 30 天內合併 PR
- 57
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
a2aproject/a2a-python 的其他 Issue
-
[Bug]: REST task/request id sanitization可能重新可做 關聯的 PR 已關閉且未合併。 未關閉maintainers-only
難度 2/5 1-3 小時 新手友好度 65/100
a2aproject/a2a-python#805 · 1 則留言 ·
維護者通常 2 天內回覆
-
[Bug]: v0.3 JSON-RPC `tasks/pushNotificationConfig/delete` succeeds with no `result` member可能已有人在做 @rohityan 今天認領。 未關閉
a2aproject/a2a-python#1480 · 已指派 2 人 ·
維護者通常 2 天內回覆
-
[Bug]: JSON-RPC client ignores the JSON-RPC error body when the HTTP status is not 2xx可能已有人在做 @rohityan 於 1 天前認領。 未關閉
a2aproject/a2a-python#1475 · 已指派 1 人 ·
維護者通常 2 天內回覆
-
[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent card可能已有人在做 @rohityan 於 3 天前認領。 未關閉component: core status:awaiting response
a2aproject/a2a-python#1468 · 1 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
-
Required extensions aren't enforced, so ExtensionSupportRequiredError is never raised可能已有人在做 @rohityan 於 3 天前認領。 未關閉component: server status:awaiting response
a2aproject/a2a-python#1467 · 2 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
查看 a2aproject/a2a-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
audit-reference-check
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
site-bug triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 77/100
canonical/paas-charm#407 · 1 則留言 ·
維護者通常 5 天內回覆