[Bug]: A2ACardResolver.get_agent_card raises UnicodeDecodeError and RecursionError instead of AgentCardResolutionError
Maintainers usually reply within 2 days
@rohityan is already working on this.
Since Nov 16, 2026.
Assessment
This issue has not been assessed yet.
Description
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
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 540
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 57
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from a2aproject/a2a-python
-
[Bug]: REST task/request id sanitizationMay be free again A pull request for this issue was closed without being merged. Openmaintainers-only
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a2aproject/a2a-python#805 · 1 comment ·
Maintainers usually reply within 2 days
-
[Bug]: v0.3 JSON-RPC `tasks/pushNotificationConfig/delete` succeeds with no `result` memberPossibly taken @rohityan claimed this today. Open
a2aproject/a2a-python#1480 · 2 assignees ·
Maintainers usually reply within 2 days
-
[Bug]: JSON-RPC client ignores the JSON-RPC error body when the HTTP status is not 2xxPossibly taken @rohityan claimed this 1 day ago. Open
a2aproject/a2a-python#1475 · 1 assignee ·
Maintainers usually reply within 2 days
-
[Feat]: validate_input_modes: match media ranges such as image/* declared in the agent cardPossibly taken @rohityan claimed this 3 days ago. Opencomponent: core status:awaiting response
a2aproject/a2a-python#1468 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
-
Required extensions aren't enforced, so ExtensionSupportRequiredError is never raisedPossibly taken @rohityan claimed this 3 days ago. Opencomponent: server status:awaiting response
a2aproject/a2a-python#1467 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
All issues in a2aproject/a2a-python
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
canonical/paas-charm#407 · 1 comment ·
Maintainers usually reply within 5 days
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
FAIRmat-NFDI/pynxtools-spm#136 ·
Maintainers usually reply within 1 day
-
enhancement tooling
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
`read_nexus` entry point points to a function that no longer existsPossibly taken @RubelMozumder claimed this today. Openannotator bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
FAIRmat-NFDI/pynxtools#876 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: HTTP 499 (Client Closed Request) is classified as a non-retryable format_error, so a mid-flight abort fails the turn over instead of retryingPossibly taken @yipinghuang1991 claimed this today. Opencomp/agent P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NousResearch/hermes-agent#156837 ·
Maintainers usually reply within 1 day