Skip to content

Commit bbcfabf

Browse files
committed
AddJSONRpcError as A2AError since it is a superset of all JSONRpcErrors
1 parent c48604d commit bbcfabf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/a2a/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ class A2AError(
999999
| UnsupportedOperationError
10001000
| ContentTypeNotSupportedError
10011001
| InvalidAgentResponseError
1002+
| JSONRPCError
10021003
]
10031004
):
10041005
root: (
@@ -1013,6 +1014,7 @@ class A2AError(
10131014
| UnsupportedOperationError
10141015
| ContentTypeNotSupportedError
10151016
| InvalidAgentResponseError
1017+
| JSONRPCError
10161018
)
10171019
"""
10181020
A discriminated union of all standard JSON-RPC and A2A-specific error types.

tests/test_types.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,14 @@ def test_a2a_error_validation_and_serialization() -> None:
14871487
a2a_err_content = A2AError.model_validate(content_type_err_data)
14881488
assert isinstance(a2a_err_content.root, ContentTypeNotSupportedError)
14891489

1490-
# 11. Test invalid data (doesn't match any known error code/structure)
1491-
invalid_data: dict[str, Any] = {'code': -99999, 'message': 'Unknown error'}
1490+
# 11. Test JSONRPCError
1491+
json_rpc_err_instance = JSONRPCError(code=1234, message='Generic error')
1492+
json_rpc_err_data = json_rpc_err_instance.model_dump(exclude_none=True)
1493+
a2a_err_content = A2AError.model_validate(json_rpc_err_data)
1494+
assert isinstance(a2a_err_content.root, JSONRPCError)
1495+
1496+
# 12. Test invalid data (doesn't match any known error code/structure)
1497+
invalid_data: dict[str, Any] = {'code': -99999, 'messages': 'Unknown error'}
14921498
with pytest.raises(ValidationError):
14931499
A2AError.model_validate(invalid_data)
14941500

0 commit comments

Comments
 (0)