Repository navigation
Conversation
🧪 Code Coverage (vs
|
Member
|
Thanks for the PR, but we are closing this without merging:
|
4 tasks done
Iwaniukooo11
added a commit
that referenced
this pull request
Nov 30, 2026
…ot decode (#1540) # Description `get_agent_card()` now raises `AgentCardResolutionError` for a card body that `response.json()` rejects with `UnicodeDecodeError` (not UTF-8) or `RecursionError` (deep nesting), with the same message as a `JSONDecodeError`. The Latin-1 test decodes a real body. The recursion test raises `RecursionError` from `response.json()` directly. On Python 3.14 the stack size sets the recursion limit, so no fixed depth reaches it on every runner. #1523 lost its `RecursionError` test to the same problem. ```console $ uv run pytest tests/client/test_card_resolver.py # 145015f, card_resolver.py from 211d13a, new tests kept FAILED tests/client/test_card_resolver.py::TestGetAgentCard::test_get_agent_card_undecodable_body FAILED tests/client/test_card_resolver.py::TestGetAgentCard::test_get_agent_card_recursion_error 2 failed, 47 passed, 1 warning $ uv run pytest tests/client/test_card_resolver.py # 145015f, Python 3.10.21 and 3.14.7 49 passed, 1 warning $ uv run pytest -n 4 --cov=a2a --cov-report term --cov-fail-under=88 # 145015f, Python 3.10.21 Required test coverage of 88% reached. Total coverage: 94.12% 2810 passed, 215 skipped, 4 xfailed, 1 xpassed, 219 warnings $ uv run ruff check && uv run ruff format --check && uv run ty check # ruff 0.15.16 All checks passed! 296 files already formatted Found 3 diagnostics # the 3 unused type: ignore warnings already on main, in files this does not touch # not run: the Postgres and MySQL suites (no DSN set here) ``` @rohityan this follows your note on #1478: the three exceptions are caught around `response.json()` only, so a `JSONDecodeError` from a `signature_verifier` now propagates where it used to read "Failed to parse JSON for agent card". - [x] Follow the [`CONTRIBUTING` Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - [x] Ensure the tests and linter pass (Run `bash scripts/format.sh` from the repository root to format) - [x] Appropriate docs were updated (if necessary) - None needed: the docstring already promises this error. Fixes #1478 --------- Signed-off-by: Christopher Krah <[email protected]> Co-authored-by: Mateusz Iwaniuk <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Unary client transports leaked builtin
UnicodeDecodeError/RecursionErrorwhen a remote response body was invalid UTF-8 or deeply nested JSON.handle_http_exceptions()caught onlyjson.JSONDecodeError, which is a differentValueErrorsubclass, so those failures escaped instead of becoming the documentedA2AClientError. This affected every unary JsonRpcTransport and RestTransport call.Fix: catch
(json.JSONDecodeError, UnicodeDecodeError, RecursionError)explicitly and raiseA2AClientError("Malformed JSON response: ...") from e, preserving__cause__. The block still lets otherValueErrors from the status error handlers propagate, so the catch was not broadened to bareValueError.Verification
MockTransportregression test parametrized over invalid UTF-8 and 10k-deep nested bodies. Base-red: 2 failed with the leaked builtin exceptions; with fix the module is 18/18, all transports 205/205, all client tests 331/331.ruff check,ruff format --checkandty checkon the changed file all pass. Full-repotyhas 11 pre-existing diagnostics in unrelated files.No live server or network used; streaming path and httpx2 alternate client not exercised.
Related to #1478 (same failure class on a different surface; no separate issue was filed for this helper). 🦕