File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ def _register_defaults(
9191 if GrpcTransport is None :
9292 raise ImportError (
9393 'To use GrpcClient, its dependencies must be installed. '
94- 'You can install them with \' pip install "a2a-sdk[grpc]"\' '
94+ 'You can install them with \' pip install "a2a-sdk[grpc]"\' ' ,
9595 )
9696 self .register (
9797 TransportProtocol .grpc ,
@@ -124,6 +124,14 @@ def create(
124124 If there is no valid matching of the client configuration with the
125125 server configuration, a `ValueError` is raised.
126126 """
127+ valid_transports = {member .value for member in TransportProtocol }
128+ for transport in self ._config .supported_transports :
129+ if transport not in valid_transports :
130+ raise ValueError (
131+ f"Unsupported transport type in ClientConfig: '{ transport } '. "
132+ f'Valid types are: { ", " .join (sorted (valid_transports ))} ' ,
133+ )
134+
127135 server_preferred = card .preferred_transport or TransportProtocol .jsonrpc
128136 server_set = {server_preferred : card .url }
129137 if card .additional_interfaces :
Original file line number Diff line number Diff line change @@ -103,3 +103,19 @@ def test_client_factory_no_compatible_transport(base_agent_card: AgentCard):
103103 factory = ClientFactory (config )
104104 with pytest .raises (ValueError , match = 'no compatible transports found' ):
105105 factory .create (base_agent_card )
106+
107+
108+ def test_client_factory_invalid_transport_in_config (base_agent_card : AgentCard ):
109+ """Verify that the factory raises an error for an unknown transport type."""
110+ config = ClientConfig (
111+ httpx_client = httpx .AsyncClient (),
112+ supported_transports = [
113+ TransportProtocol .jsonrpc ,
114+ 'invalid-transport-protocol' ,
115+ ],
116+ )
117+ factory = ClientFactory (config )
118+ with pytest .raises (
119+ ValueError , match = 'Unsupported transport type in ClientConfig'
120+ ):
121+ factory .create (base_agent_card )
You can’t perform that action at this time.
0 commit comments