Skip to content

Commit 627ae0b

Browse files
authored
fix: remove v1 from HTTP+REST/JSON paths (#765)
This was removed in a2aproject/A2A#1269 for `a2a.proto` and does not exist in [5.3. Method Mapping Reference](https://a2a-protocol.org/latest/specification/#53-method-mapping-reference). Re #559.
1 parent 12b5edf commit 627ae0b

6 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/a2a/client/transports/rest.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def send_message(
7878
request, context, extensions
7979
)
8080
response_data = await self._send_post_request(
81-
'/v1/message:send', payload, modified_kwargs
81+
'/message:send', payload, modified_kwargs
8282
)
8383
response: SendMessageResponse = ParseDict(
8484
response_data, SendMessageResponse()
@@ -99,7 +99,7 @@ async def send_message_streaming(
9999

100100
async for event in self._send_stream_request(
101101
'POST',
102-
'/v1/message:stream',
102+
'/message:stream',
103103
http_kwargs=modified_kwargs,
104104
json=payload,
105105
):
@@ -128,7 +128,7 @@ async def get_task(
128128
del params['id'] # id is part of the URL path, not query params
129129

130130
response_data = await self._send_get_request(
131-
f'/v1/tasks/{request.id}',
131+
f'/tasks/{request.id}',
132132
params,
133133
modified_kwargs,
134134
)
@@ -153,7 +153,7 @@ async def list_tasks(
153153
extensions if extensions is not None else self.extensions,
154154
)
155155
response_data = await self._send_get_request(
156-
'/v1/tasks',
156+
'/tasks',
157157
_model_to_query_params(request),
158158
modified_kwargs,
159159
)
@@ -181,7 +181,7 @@ async def cancel_task(
181181
context,
182182
)
183183
response_data = await self._send_post_request(
184-
f'/v1/tasks/{request.id}:cancel', payload, modified_kwargs
184+
f'/tasks/{request.id}:cancel', payload, modified_kwargs
185185
)
186186
response: Task = ParseDict(response_data, Task())
187187
return response
@@ -203,7 +203,7 @@ async def create_task_push_notification_config(
203203
payload, modified_kwargs, context
204204
)
205205
response_data = await self._send_post_request(
206-
f'/v1/tasks/{request.task_id}/pushNotificationConfigs',
206+
f'/tasks/{request.task_id}/pushNotificationConfigs',
207207
payload,
208208
modified_kwargs,
209209
)
@@ -235,7 +235,7 @@ async def get_task_push_notification_config(
235235
if 'task_id' in params:
236236
del params['task_id']
237237
response_data = await self._send_get_request(
238-
f'/v1/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
238+
f'/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
239239
params,
240240
modified_kwargs,
241241
)
@@ -265,7 +265,7 @@ async def list_task_push_notification_configs(
265265
if 'task_id' in params:
266266
del params['task_id']
267267
response_data = await self._send_get_request(
268-
f'/v1/tasks/{request.task_id}/pushNotificationConfigs',
268+
f'/tasks/{request.task_id}/pushNotificationConfigs',
269269
params,
270270
modified_kwargs,
271271
)
@@ -297,7 +297,7 @@ async def delete_task_push_notification_config(
297297
if 'task_id' in params:
298298
del params['task_id']
299299
await self._send_delete_request(
300-
f'/v1/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
300+
f'/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
301301
params,
302302
modified_kwargs,
303303
)
@@ -317,7 +317,7 @@ async def subscribe(
317317

318318
async for event in self._send_stream_request(
319319
'GET',
320-
f'/v1/tasks/{request.id}:subscribe',
320+
f'/tasks/{request.id}:subscribe',
321321
http_kwargs=modified_kwargs,
322322
):
323323
yield event
@@ -345,7 +345,7 @@ async def get_extended_agent_card(
345345
context,
346346
)
347347
response_data = await self._send_get_request(
348-
'/v1/card', {}, modified_kwargs
348+
'/card', {}, modified_kwargs
349349
)
350350
response: AgentCard = ParseDict(response_data, AgentCard())
351351

src/a2a/server/apps/rest/rest_adapter.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,53 +206,53 @@ def routes(self) -> dict[tuple[str, str], Callable[[Request], Any]]:
206206
the value is the callable handler for that route.
207207
"""
208208
routes: dict[tuple[str, str], Callable[[Request], Any]] = {
209-
('/v1/message:send', 'POST'): functools.partial(
209+
('/message:send', 'POST'): functools.partial(
210210
self._handle_request, self.handler.on_message_send
211211
),
212-
('/v1/message:stream', 'POST'): functools.partial(
212+
('/message:stream', 'POST'): functools.partial(
213213
self._handle_streaming_request,
214214
self.handler.on_message_send_stream,
215215
),
216-
('/v1/tasks/{id}:cancel', 'POST'): functools.partial(
216+
('/tasks/{id}:cancel', 'POST'): functools.partial(
217217
self._handle_request, self.handler.on_cancel_task
218218
),
219-
('/v1/tasks/{id}:subscribe', 'GET'): functools.partial(
219+
('/tasks/{id}:subscribe', 'GET'): functools.partial(
220220
self._handle_streaming_request,
221221
self.handler.on_subscribe_to_task,
222222
),
223-
('/v1/tasks/{id}', 'GET'): functools.partial(
223+
('/tasks/{id}', 'GET'): functools.partial(
224224
self._handle_request, self.handler.on_get_task
225225
),
226226
(
227-
'/v1/tasks/{id}/pushNotificationConfigs/{push_id}',
227+
'/tasks/{id}/pushNotificationConfigs/{push_id}',
228228
'GET',
229229
): functools.partial(
230230
self._handle_request, self.handler.get_push_notification
231231
),
232232
(
233-
'/v1/tasks/{id}/pushNotificationConfigs/{push_id}',
233+
'/tasks/{id}/pushNotificationConfigs/{push_id}',
234234
'DELETE',
235235
): functools.partial(
236236
self._handle_request, self.handler.delete_push_notification
237237
),
238238
(
239-
'/v1/tasks/{id}/pushNotificationConfigs',
239+
'/tasks/{id}/pushNotificationConfigs',
240240
'POST',
241241
): functools.partial(
242242
self._handle_request, self.handler.set_push_notification
243243
),
244244
(
245-
'/v1/tasks/{id}/pushNotificationConfigs',
245+
'/tasks/{id}/pushNotificationConfigs',
246246
'GET',
247247
): functools.partial(
248248
self._handle_request, self.handler.list_push_notifications
249249
),
250-
('/v1/tasks', 'GET'): functools.partial(
250+
('/tasks', 'GET'): functools.partial(
251251
self._handle_request, self.handler.list_tasks
252252
),
253253
}
254254
if self.agent_card.capabilities.extended_agent_card:
255-
routes[('/v1/card', 'GET')] = functools.partial(
255+
routes[('/card', 'GET')] = functools.partial(
256256
self._handle_request, self.handle_authenticated_agent_card
257257
)
258258

src/a2a/server/request_handlers/rest_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ async def on_get_task(
238238
request: Request,
239239
context: ServerCallContext,
240240
) -> dict[str, Any]:
241-
"""Handles the 'v1/tasks/{id}' REST method.
241+
"""Handles the 'tasks/{id}' REST method.
242242
243243
Args:
244244
request: The incoming `Request` object.

tests/client/transports/test_rest_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ async def test_list_task_push_notification_configs_success(
365365
mock_build_request.assert_called_once()
366366
call_args = mock_build_request.call_args
367367
assert call_args[0][0] == 'GET'
368-
assert f'/v1/tasks/{task_id}/pushNotificationConfigs' in call_args[0][1]
368+
assert f'/tasks/{task_id}/pushNotificationConfigs' in call_args[0][1]
369369

370370
@pytest.mark.asyncio
371371
async def test_delete_task_push_notification_config_success(
@@ -399,6 +399,6 @@ async def test_delete_task_push_notification_config_success(
399399
call_args = mock_build_request.call_args
400400
assert call_args[0][0] == 'DELETE'
401401
assert (
402-
f'/v1/tasks/{task_id}/pushNotificationConfigs/config-1'
402+
f'/tasks/{task_id}/pushNotificationConfigs/config-1'
403403
in call_args[0][1]
404404
)

tests/e2e/push_notifications/test_default_push_notification_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def agent_server(notifications_client: httpx.AsyncClient):
7474
)
7575
process.start()
7676
try:
77-
wait_for_server_ready(f'{url}/v1/card')
77+
wait_for_server_ready(f'{url}/card')
7878
except TimeoutError as e:
7979
process.terminate()
8080
raise e

tests/server/apps/rest/test_rest_fastapi_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async def test_send_message_success_message(
200200
)
201201
# To see log output, run pytest with '--log-cli=true --log-cli-level=INFO'
202202
response = await client.post(
203-
'/v1/message:send', json=json_format.MessageToDict(request)
203+
'/message:send', json=json_format.MessageToDict(request)
204204
)
205205
# request should always be successful
206206
response.raise_for_status()
@@ -249,7 +249,7 @@ async def test_send_message_success_task(
249249
)
250250
# To see log output, run pytest with '--log-cli=true --log-cli-level=INFO'
251251
response = await client.post(
252-
'/v1/message:send', json=json_format.MessageToDict(request)
252+
'/message:send', json=json_format.MessageToDict(request)
253253
)
254254
# request should always be successful
255255
response.raise_for_status()
@@ -298,7 +298,7 @@ async def mock_stream_response():
298298

299299
# This should not hang indefinitely (previously it would due to the deadlock)
300300
response = await streaming_client.post(
301-
'/v1/message:stream',
301+
'/message:stream',
302302
json=json_format.MessageToDict(request),
303303
headers={'Accept': 'text/event-stream'},
304304
timeout=10.0, # Reasonable timeout to prevent hanging in tests
@@ -339,7 +339,7 @@ async def mock_stream_response():
339339

340340
# Send request without proper event-stream headers
341341
response = await streaming_client.post(
342-
'/v1/message:stream',
342+
'/message:stream',
343343
json=json_format.MessageToDict(request),
344344
timeout=10.0,
345345
)
@@ -387,7 +387,7 @@ async def test_send_message_rejected_task(
387387
)
388388

389389
response = await client.post(
390-
'/v1/message:send', json=json_format.MessageToDict(request)
390+
'/message:send', json=json_format.MessageToDict(request)
391391
)
392392

393393
response.raise_for_status()

0 commit comments

Comments
 (0)