UAT: A2aOperationNotFoundError re-raised instead of returning JSON-RPC -32601 error response #6614

Open
opened 2026-04-09 22:19:16 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area: A2A Protocol — A2A Facade dispatch error handling

Spec Reference

docs/reference/a2a.md — Error Code Taxonomy table:

JSON-RPC Code Domain Exception(s) Meaning
-32601 A2aOperationNotFoundError Method not found

The spec states that domain exceptions are mapped to JSON-RPC 2.0 error codes and that the facade returns an A2aResponse with error set on failure.

Expected Behavior

When an unknown A2A method is dispatched, A2aLocalFacade.dispatch() should return an A2aResponse with:

{
  "jsonrpc": "2.0",
  "id": "<request_id>",
  "error": {
    "code": -32601,
    "message": "Unknown A2A method: <method_name>"
  }
}

Actual Behavior

A2aLocalFacade.dispatch() re-raises A2aOperationNotFoundError instead of catching it and returning an error response:

# src/cleveragents/a2a/facade.py, dispatch() method
except A2aOperationNotFoundError:
    raise  # ← BUG: should be caught and returned as error response
except Exception as exc:
    # ... maps to error response correctly

This means callers receive an unhandled exception instead of a structured JSON-RPC error response, breaking the A2A protocol contract.

Code Location

src/cleveragents/a2a/facade.py, dispatch() method, lines ~175-195:

def dispatch(self, request: A2aRequest) -> A2aResponse:
    ...
    try:
        data = self._route_operation(request.method, request.params)
        ...
        return A2aResponse(id=request.id, result=data)
    except A2aOperationNotFoundError:
        raise  # ← Should be caught and returned as A2aResponse with error code -32601
    except Exception as exc:
        code, message = map_domain_error(exc)
        ...
        return A2aResponse(id=request.id, error=A2aErrorDetail(code=code, message=message))

Root Cause

A2aOperationNotFoundError is explicitly excluded from the general exception handler that maps domain errors to A2A error responses. The map_domain_error() function in errors.py also does not handle A2aOperationNotFoundError, so even if the re-raise were removed, it would fall through to the generic INTERNAL_ERROR (-32603) mapping instead of the correct -32601.

Fix Required

  1. In facade.py, remove the except A2aOperationNotFoundError: raise block and let it fall through to the general handler, OR catch it explicitly and return an error response with code -32601.
  2. In errors.py, add A2aOperationNotFoundError to map_domain_error() to return (-32601, str(exc)).

Steps to Reproduce

from cleveragents.a2a.facade import A2aLocalFacade
from cleveragents.a2a.models import A2aRequest

facade = A2aLocalFacade()
# This raises A2aOperationNotFoundError instead of returning an error response
response = facade.dispatch(A2aRequest(method="nonexistent/operation"))

Impact

  • Protocol violation: A2A clients expect a JSON-RPC error response for unknown methods, not an exception
  • Breaks all A2A consumers: Any code calling dispatch() with an unknown method will crash unless it explicitly catches A2aOperationNotFoundError
  • The facade docstring says "Domain exceptions are mapped to A2A error codes via map_domain_error" — this is violated for A2aOperationNotFoundError

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area:** A2A Protocol — A2A Facade dispatch error handling ### Spec Reference `docs/reference/a2a.md` — Error Code Taxonomy table: | JSON-RPC Code | Domain Exception(s) | Meaning | |---|---|---| | `-32601` | `A2aOperationNotFoundError` | Method not found | The spec states that domain exceptions are mapped to JSON-RPC 2.0 error codes and that the facade returns an `A2aResponse` with `error` set on failure. ### Expected Behavior When an unknown A2A method is dispatched, `A2aLocalFacade.dispatch()` should return an `A2aResponse` with: ```json { "jsonrpc": "2.0", "id": "<request_id>", "error": { "code": -32601, "message": "Unknown A2A method: <method_name>" } } ``` ### Actual Behavior `A2aLocalFacade.dispatch()` **re-raises** `A2aOperationNotFoundError` instead of catching it and returning an error response: ```python # src/cleveragents/a2a/facade.py, dispatch() method except A2aOperationNotFoundError: raise # ← BUG: should be caught and returned as error response except Exception as exc: # ... maps to error response correctly ``` This means callers receive an unhandled exception instead of a structured JSON-RPC error response, breaking the A2A protocol contract. ### Code Location `src/cleveragents/a2a/facade.py`, `dispatch()` method, lines ~175-195: ```python def dispatch(self, request: A2aRequest) -> A2aResponse: ... try: data = self._route_operation(request.method, request.params) ... return A2aResponse(id=request.id, result=data) except A2aOperationNotFoundError: raise # ← Should be caught and returned as A2aResponse with error code -32601 except Exception as exc: code, message = map_domain_error(exc) ... return A2aResponse(id=request.id, error=A2aErrorDetail(code=code, message=message)) ``` ### Root Cause `A2aOperationNotFoundError` is explicitly excluded from the general exception handler that maps domain errors to A2A error responses. The `map_domain_error()` function in `errors.py` also does not handle `A2aOperationNotFoundError`, so even if the re-raise were removed, it would fall through to the generic `INTERNAL_ERROR` (-32603) mapping instead of the correct `-32601`. ### Fix Required 1. In `facade.py`, remove the `except A2aOperationNotFoundError: raise` block and let it fall through to the general handler, OR catch it explicitly and return an error response with code `-32601`. 2. In `errors.py`, add `A2aOperationNotFoundError` to `map_domain_error()` to return `(-32601, str(exc))`. ### Steps to Reproduce ```python from cleveragents.a2a.facade import A2aLocalFacade from cleveragents.a2a.models import A2aRequest facade = A2aLocalFacade() # This raises A2aOperationNotFoundError instead of returning an error response response = facade.dispatch(A2aRequest(method="nonexistent/operation")) ``` ### Impact - **Protocol violation**: A2A clients expect a JSON-RPC error response for unknown methods, not an exception - **Breaks all A2A consumers**: Any code calling `dispatch()` with an unknown method will crash unless it explicitly catches `A2aOperationNotFoundError` - The facade docstring says "Domain exceptions are mapped to A2A error codes via `map_domain_error`" — this is violated for `A2aOperationNotFoundError` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 22:25:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#6614
No description provided.