You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6cce91b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(server): reject terminal-task operations with UnsupportedOperationError (a2aproject#1268)
## What
Spec
[3.1.1](https://a2a-protocol.org/latest/specification/#311-send-message)
names `UnsupportedOperationError` for "Messages sent to Tasks that are
in a terminal state", and 3.3.2 repeats it for any operation on a
terminal task. 5.4 maps that to `-32004` / `FAILED_PRECONDITION` / HTTP
400. `ActiveTask` raised `InvalidParamsError` (`-32602`) instead, at all
three of its terminal-state guards.
That covers both `send_message` and `subscribe_to_task`, because
`DefaultRequestHandlerV2.on_subscribe_to_task` has no terminal check of
its own: it calls `get_or_create`, which calls `ActiveTask.start()`, and
the error surfaces out of the first `__anext__`.
Worth knowing while reading: `DefaultRequestHandler` is an alias for
`DefaultRequestHandlerV2` (`request_handlers/__init__.py:46`), so
`default_request_handler.py` is the legacy handler and is not on the
default path. It already answered subscribe correctly at line 613, which
is why only the v2 path drifted. Its send path is corrected here too, so
the two handlers and the two operations finally agree.
## Cancel keeps its own error
`on_cancel_task` deliberately catches `ActiveTask`'s terminal-state
error and re-raises `TaskNotCancelableError`, which 3.3.2 gives its own
entry. That remap is retained, now keyed on the new error type. Two ACTS
tests (`CORE-CANCEL-002`, `CORE-ERR-002`) cover it and still pass.
## Tests
`test_on_subscribe_to_task_in_terminal_state` is new for v2. Its absence
is why this survived: the legacy suite had the equivalent test and
asserted the correct error all along, so the divergence never showed up.
Mutation-checked - reverting `active_task.py:472` alone fails all four
parametrized cases.
An existing `# TODO: Is it correct error code ?` in `test_scenarios.py`
sat next to this exact assertion. It is now answered rather than carried
forward.
## Result
Clears `CORE-SEND-002`, `CORE-ERR-004` and `STREAM-SUB-003` (all `must`)
on jsonrpc, grpc and rest - 9 of the 21 failing MUST test-instances.
| binding | must before | must after |
| --- | --- | --- |
| jsonrpc | 52/59 | 55/59 |
| grpc | 40/47 | 43/47 |
| rest | 42/49 | 45/49 |
0 commit comments