From 84070afb526ff917569bcae936550cf8a7727500 Mon Sep 17 00:00:00 2001 From: saquibjawedbit <138011435+saquibjawedbit@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:52:22 +0530 Subject: [PATCH] fix(compat): percent-encode ids in v0.3 REST push config delete path `CompatRestTransport.delete_task_push_notification_config` still put the task id and the push config id into the URL path as raw text. #1458 encoded ids at the other six path sites, but the delete route was only added to the v0.3 REST server by #1442, so this one was left out. An id containing `#`, `?` or `%` then names a different resource: deleting the config `alerts#ops` sends `DELETE /v1/tasks/t1/pushNotificationConfigs/alerts` and removes the config `alerts`, leaving `alerts#ops` in place. Encode both ids with the existing `_quote_id` helper, as the get, list and create calls already do. Ids without reserved characters produce the same URL as before. --- src/a2a/compat/v0_3/rest_transport.py | 3 ++- tests/compat/v0_3/test_rest_transport.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/a2a/compat/v0_3/rest_transport.py b/src/a2a/compat/v0_3/rest_transport.py index 3f1e6b5c0..5deee4284 100644 --- a/src/a2a/compat/v0_3/rest_transport.py +++ b/src/a2a/compat/v0_3/rest_transport.py @@ -294,7 +294,8 @@ async def delete_task_push_notification_config( """Deletes the push notification configuration for a specific task.""" await self._execute_request( 'DELETE', - f'/v1/tasks/{request.task_id}/pushNotificationConfigs/{request.id}', + f'/v1/tasks/{_quote_id(request.task_id)}' + f'/pushNotificationConfigs/{_quote_id(request.id)}', context=context, ) diff --git a/tests/compat/v0_3/test_rest_transport.py b/tests/compat/v0_3/test_rest_transport.py index 551d39c35..3fc4cb063 100644 --- a/tests/compat/v0_3/test_rest_transport.py +++ b/tests/compat/v0_3/test_rest_transport.py @@ -985,3 +985,27 @@ async def test_get_task_does_not_return_task_named_by_id_prefix( # MethodNotFoundError. with pytest.raises(MethodNotFoundError): await transport.get_task(GetTaskRequest(id='t1?x')) + + @pytest.mark.asyncio + async def test_delete_push_config_does_not_delete_config_named_by_prefix( + self, transport: CompatRestTransport + ): + for config_id in ('alerts', 'alerts#ops'): + await transport.create_task_push_notification_config( + TaskPushNotificationConfig( + task_id='t1', + id=config_id, + url='https://hooks.example.com/hook', + ) + ) + + await transport.delete_task_push_notification_config( + DeleteTaskPushNotificationConfigRequest( + task_id='t1', id='alerts#ops' + ) + ) + + response = await transport.list_task_push_notification_configs( + ListTaskPushNotificationConfigsRequest(task_id='t1') + ) + assert [config.id for config in response.configs] == ['alerts']