Skip to content

Commit 270972d

Browse files
fix(compat): percent-encode ids in v0.3 REST push config delete path (#1486)
# Description The v0.3 REST client built the `DELETE /v1/tasks/{task_id}/pushNotificationConfigs/{id}` path without percent-encoding the ids. #1458 added `_quote_id` to the other six path builders in `compat/v0_3/rest_transport.py`, but the delete call was missed (its server route only landed later, in #1442). So deleting `alerts#ops` sent `.../pushNotificationConfigs/alerts#ops`; the `#ops` became a URL fragment and the server deleted `alerts` instead, leaving `alerts#ops` in place. Ids with `?` or `%` are mangled the same way. **Fix:** wrap both ids in `_quote_id`, as the get, list and create calls already do. ## Testing New case in the existing path-encoding tests in `tests/compat/v0_3/test_rest_transport.py` (real handler + real client: create `alerts` and `alerts#ops`, delete `alerts#ops`, check what's left). Before the fix: ``` AssertionError: assert ['alerts#ops'] == ['alerts'] 1 failed, 2 passed ``` After: ``` 3 passed ``` Full suite on main (a59bb68): ``` $ pytest tests --ignore=tests/integration/cross_version 2618 passed, 215 skipped, 4 xfailed, 1 xpassed ``` `ruff check` and `ruff format` pass. - [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 - [x] Appropriate docs were updated (if necessary) Fixes #1485 🦕 Co-authored-by: Mateusz Iwaniuk <45974414+Iwaniukooo11@users.noreply.github.com>
1 parent a6dd087 commit 270972d

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎src/a2a/compat/v0_3/rest_transport.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ async def delete_task_push_notification_config(
302302
"""Deletes the push notification configuration for a specific task."""
303303
await self._execute_request(
304304
'DELETE',
305-
f'/v1/tasks/{request.task_id}/pushNotificationConfigs/{request.id}',
305+
f'/v1/tasks/{_quote_id(request.task_id)}'
306+
f'/pushNotificationConfigs/{_quote_id(request.id)}',
306307
context=context,
307308
)
308309

‎tests/compat/v0_3/test_rest_transport.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,3 +990,27 @@ async def test_get_task_does_not_return_task_named_by_id_prefix(
990990
# MethodNotFoundError.
991991
with pytest.raises(MethodNotFoundError):
992992
await transport.get_task(GetTaskRequest(id='t1?x'))
993+
994+
@pytest.mark.asyncio
995+
async def test_delete_push_config_does_not_delete_config_named_by_prefix(
996+
self, transport: CompatRestTransport
997+
):
998+
for config_id in ('alerts', 'alerts#ops'):
999+
await transport.create_task_push_notification_config(
1000+
TaskPushNotificationConfig(
1001+
task_id='t1',
1002+
id=config_id,
1003+
url='https://hooks.example.com/hook',
1004+
)
1005+
)
1006+
1007+
await transport.delete_task_push_notification_config(
1008+
DeleteTaskPushNotificationConfigRequest(
1009+
task_id='t1', id='alerts#ops'
1010+
)
1011+
)
1012+
1013+
response = await transport.list_task_push_notification_configs(
1014+
ListTaskPushNotificationConfigsRequest(task_id='t1')
1015+
)
1016+
assert [config.id for config in response.configs] == ['alerts']

0 commit comments

Comments
 (0)