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

Aperta Adatta ai principianti
#1,298 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
api

Direzione di ricerca

Inizia tracciando il modo in cui il trasporto HTTP+JSON associa uno stato HTTP a TaskNotCancelableError, quindi confronta tale associazione con la tabella degli errori della specifica nella sezione 3.3.2. Esegui tests/compatibility/core_operations/test_task_lifecycle.py::TestCancelTask::test_cancel_terminal_task_returns_error[http_json] per riprodurre il problema; il risultato corretto è una risposta HTTP 400 con codice 400 e motivo TASK_NOT_CANCELABLE.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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]

Lingua principale
Java
Stelle
510
Fork
196
Merge medio
2g 4h
PR unite (30g)
57

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di a2aproject/a2a-java

Tutte le issue di a2aproject/a2a-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.