HTTP+JSON CancelTask returns 409 Conflict instead of 400 Bad Request for TaskNotCancelableError

Offen Anfängerfreundlich
#1,298 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
api

Rechercherichtung

Verfolge zunächst, wie der HTTP+JSON-Transport TaskNotCancelableError einem HTTP-Status zuordnet, und vergleiche diese Zuordnung anschließend mit der Fehlertabelle der Spezifikation in Abschnitt 3.3.2. Führe tests/compatibility/core_operations/test_task_lifecycle.py::TestCancelTask::test_cancel_terminal_task_returns_error[http_json] aus, um das Problem zu reproduzieren; erfolgreich ist der Test, wenn die Antwort HTTP 400 mit Code 400 und dem Grund TASK_NOT_CANCELABLE enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

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]

Vorherrschende Sprache
Java
Sterne
510
Forks
196
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
57

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus a2aproject/a2a-java

Alle Issues in a2aproject/a2a-java

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.