Repository navigation
Description
Summary
When canceling a task that is already in a terminal state (TASK_STATE_COMPLETED), the HTTP+JSON transport returns 409 Conflict instead of 400 Bad Request as required by the A2A specification's error mapping table.
Requirement
- ID: CORE-CANCEL-002
- Section: 3.1.5 — CancelTask returns TaskNotCancelableError for terminal tasks
- Level: MUST
- Spec: https://github.com/a2aproject/A2A/blob/3303592588e388e62e0f69f701af531d2f4e3991/docs/specification.md#315-cancel-task
Specification
CancelTask MUST return TaskNotCancelableError when the task is not in a cancelable state (already completed, failed, or canceled).
The error mapping table in section 3.3.2 specifies:
| Error Name | JSON-RPC | gRPC | HTTP |
|---|---|---|---|
TaskNotCancelableError |
-32002 |
FAILED_PRECONDITION |
400 Bad Request |
Expected behavior
The HTTP+JSON transport should return HTTP status 400 Bad Request with an AIP-193 error body containing "code": 400 and an ErrorInfo detail with "reason": "TASK_NOT_CANCELABLE".
Actual behavior
The SUT returns HTTP 409 Conflict with "code": 409 and "status": "FAILED_PRECONDITION":
{
"error": {
"code": 409,
"status": "FAILED_PRECONDITION",
"message": "Task cannot be canceled - current state: TASK_STATE_COMPLETED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "TASK_NOT_CANCELABLE",
"domain": "a2a-protocol.org",
"metadata": {}
}
]
}
}Note: The reason and error structure are correct — only the HTTP status code is wrong.
Reproducer
# 1. Create a task that completes immediately
TASK_ID=$(curl -s -X POST "http://localhost:9999/message:send" \
-H "Content-Type: application/json" \
-H "A2A-Version: 1.0" \
-d '{"message":{"role":"ROLE_USER","parts":[{"text":"TCK prerequisite task creation"}],"messageId":"tck-complete-task-repro"},"configuration":{"acceptedOutputModes":["text"]}}' \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d['task']['id'])")
# 2. Verify the task is completed
curl -s -X GET "http://localhost:9999/tasks/$TASK_ID" \
-H "A2A-Version: 1.0" \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d['status']['state'])"
# → TASK_STATE_COMPLETED
# 3. Attempt to cancel the completed task (expect 400, get 409)
curl -s -w "\nHTTP Status: %{http_code}\n" -X POST "http://localhost:9999/tasks/$TASK_ID:cancel" \
-H "A2A-Version: 1.0"
# → HTTP Status: 409 (should be 400)TCK test
tests/compatibility/core_operations/test_task_lifecycle.py::TestCancelTask::test_cancel_terminal_task_returns_error[http_json]
Activity
ravismash commentedon Nov 7, 2026
I'd like to take this.
TASK_NOT_CANCELABLEis mapped to 409 inA2AErrorCodes. Comparing the rest of that enum with the table in section 5.4 of the spec (v1.0.1, same in v1.1.0-rc), I found five more differences:TaskNotCancelableErrorFAILED_PRECONDITION/ 409FAILED_PRECONDITION/ 400PushNotificationNotSupportedErrorUNIMPLEMENTED/ 400FAILED_PRECONDITION/ 400UnsupportedOperationErrorUNIMPLEMENTED/ 400FAILED_PRECONDITION/ 400ContentTypeNotSupportedErrorINVALID_ARGUMENT/ 415INVALID_ARGUMENT/ 400InvalidAgentResponseErrorINTERNAL/ 502INTERNAL/ 500VersionNotSupportedErrorUNIMPLEMENTED/ 400FAILED_PRECONDITION/ 400For the gRPC ones,
GrpcErrorMapperalready reads theErrorInforeason first, so clients of this SDK would keep working. Only its status-code fallback (UNIMPLEMENTED→UnsupportedOperationError) is affected, and it could stay as is for older servers.Should I fix only the 409 here, as the issue describes, or align the whole table in one PR (or the HTTP codes here and the gRPC codes in a follow-up)? Some of these may be deliberate, so I'd rather check first.
kabir commentedon Nov 9, 2026
Hi, we support version 1.0 of the spec. The 1.0.1 release didn't seem to be properly published (the last version on the site is shown as 1.1.0) , and the A2A-version header is 1.0 in both 1.0 and 1.0.1, so there is no way to distinguish between 1.0.0 and 1.0.1. So we're stuck on 1.0. It doesn't make sense to use 1.0.1 error mappings when we can't distinguish the exact protocol used.
For 1.1.0 we will support this quickly after it is added, but probably add some kind of compat layer to support that along with 1.0.
ravismash commentedon Nov 9, 2026
Thanks, that makes sense. I diffed the spec tags: the current
A2AErrorCodesmatches the v1.0.0 table exactly, and all six rows I listed were changed in v1.0.1 (they stay the same in v1.1.0-rc). So this is a 1.0 vs 1.0.1 difference rather than a bug against 1.0, and the TCK test is checking the newer codes.When 1.1 support starts, I'd be glad to take the error-mapping part of the compat layer: choose the HTTP and gRPC codes from the version
VersionRouterresolves, soA2A-Version: 1.0keeps today's codes and1.1gets the new table, with tests for both versions. Should I wait for a 1.1 tracking issue, or is this one the place to hang it on?kabir commentedon Nov 9, 2026
I've opened #1303, and done some preliminary investigation into how to do this in the branch linked from the issue. Note this is just me putting an agent onto it. I've not evaluated yet what it said. I will get back to this later this week
ravismash commentedon Nov 9, 2026
Thanks, that makes sense. I diffed the spec tags: the current
A2AErrorCodesmatches the v1.0.0 table exactly, and all six rows I listed were changed in v1.0.1 (they stay the same in v1.1.0-rc). So this is a 1.0 vs 1.0.1 difference rather than a bug against 1.0, and the TCK test is checking the newer codes.When 1.1 support starts, I'd be glad to take the error-mapping part of the compat layer: choose the HTTP and gRPC codes from the version
VersionRouterresolves, soA2A-Version: 1.0keeps today's codes and1.1gets the new table, with tests for both versions. Should I wait for a 1.1 tracking issue, or is this one the place to hang it on?