Skip to content

fix(client): wrap UnicodeDecodeError and RecursionError in AgentCardResolutionError - #1539

Closed
fanjiahe wants to merge 1 commit into
a2aproject:mainfrom
fanjiahe:fix/card-resolver-decode-errors
Closed

fanjiahe wants to merge 1 commit into
a2aproject:mainfrom
fanjiahe:fix/card-resolver-decode-errors

Conversation

@fanjiahe

Copy link
Copy Markdown

Fixes #1478

Summary

  • Catch (json.JSONDecodeError, UnicodeDecodeError, RecursionError) in A2ACardResolver.get_agent_card() so non-UTF-8 response payloads (e.g., Latin-1) and deeply nested JSON bodies raise AgentCardResolutionError as documented instead of leaking built-in exceptions.
  • Leave ValueError uncaught so exceptions raised by caller-supplied signature_verifier callbacks are not masked.
  • Add MockTransport regression tests in tests/client/test_card_resolver.py covering non-UTF-8 bytes, deeply nested JSON, and unmasked signature_verifier errors.

Verification

  • ruff format --check src/a2a/client/card_resolver.py tests/client/test_card_resolver.py -> 2 files already formatted
  • ruff check src/a2a/client/card_resolver.py tests/client/test_card_resolver.py -> All checks passed
  • pytest tests/client/test_card_resolver.py tests/client/test_errors.py -q -> 56 passed

Disclosure: This PR was developed with AI assistance.

@fanjiahe
fanjiahe requested a review from a team as a code owner November 27, 2026 13:36
Copilot AI balanced review requested due to automatic review settings November 27, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Iwaniukooo11

Copy link
Copy Markdown
Member

Closing as a duplicate of #1540 + CI tests are not passing

@Iwaniukooo11 Iwaniukooo11 self-assigned this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A2ACardResolver.get_agent_card raises UnicodeDecodeError and RecursionError instead of AgentCardResolutionError

3 participants