Skip to content

Commit df8d006

Browse files
committed
fix error handling in request handler
1 parent 967ada3 commit df8d006

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/a2a/server/request_handlers/default_request_handler_v2.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
PushNotificationNotSupportedError,
4747
TaskNotCancelableError,
4848
TaskNotFoundError,
49-
UnsupportedOperationError,
5049
)
5150
from a2a.utils.helpers import maybe_await
5251
from a2a.utils.task import (
@@ -383,7 +382,7 @@ async def on_get_task_push_notification_config( # noqa: D102
383382
if config.id == config_id:
384383
return config
385384

386-
raise InternalError(message='Push notification config not found')
385+
raise TaskNotFoundError
387386

388387
@validate_request_params
389388
@validate(
@@ -418,7 +417,7 @@ async def on_list_task_push_notification_configs( # noqa: D102
418417
context: ServerCallContext,
419418
) -> ListTaskPushNotificationConfigsResponse:
420419
if not self._push_config_store:
421-
raise UnsupportedOperationError
420+
raise PushNotificationNotSupportedError
422421

423422
task_id = params.task_id
424423
task: Task | None = await self.task_store.get(task_id, context)
@@ -445,7 +444,7 @@ async def on_delete_task_push_notification_config( # noqa: D102
445444
context: ServerCallContext,
446445
) -> None:
447446
if not self._push_config_store:
448-
raise UnsupportedOperationError
447+
raise PushNotificationNotSupportedError
449448

450449
task_id = params.task_id
451450
config_id = params.id

tests/server/request_handlers/test_default_request_handler_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ async def test_get_task_push_notification_config_info_not_found():
446446
task_id='non_existent_task', id='task_push_notification_config'
447447
)
448448
context = create_server_call_context()
449-
with pytest.raises(InternalError):
449+
with pytest.raises(TaskNotFoundError):
450450
await request_handler.on_get_task_push_notification_config(
451451
params, context
452452
)

0 commit comments

Comments
 (0)