UAT: map_domain_error() missing A2aOperationNotFoundError → -32601 and A2aVersionMismatchError → -32007 mappings — wrong error codes returned #5093

Open
opened 2026-04-09 01:00:40 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: A2A Protocol — error code mapping
Severity: Medium — incorrect JSON-RPC 2.0 error codes returned for method-not-found and version-mismatch errors


What Was Tested

Code-level analysis of src/cleveragents/a2a/errors.py — the map_domain_error() function and error code constants.

Expected Behavior (from spec)

Per ADR-047 (A2A Standard Adoption), the error code taxonomy maps:

Code Meaning Domain Exception
-32601 Method not found A2aOperationNotFoundError
-32007 Version mismatch A2aVersionMismatchError

The map_domain_error() function is the canonical mapping from domain exceptions to JSON-RPC 2.0 error codes. It should handle all A2A-specific exceptions.

Actual Behavior

File: src/cleveragents/a2a/errors.py

Missing constants:

# Defined in comments but NOT as constants:
#   -32601  Method not found   ← no METHOD_NOT_FOUND constant
#   -32007  Version mismatch   ← no VERSION_MISMATCH constant

map_domain_error() missing cases:

def map_domain_error(exc: Exception) -> tuple[int, str]:
    if isinstance(exc, ResourceNotFoundError):
        return NOT_FOUND, str(exc)
    if isinstance(exc, ValidationError):
        return VALIDATION_ERROR, str(exc)
    if isinstance(exc, PlanError):
        return PLAN_ERROR, str(exc)
    if isinstance(exc, BusinessRuleViolation):
        return INVALID_STATE, str(exc)
    if isinstance(exc, AuthenticationError):
        return AUTH_ERROR, str(exc)
    if isinstance(exc, AuthorizationError):
        return FORBIDDEN, str(exc)
    if isinstance(exc, ConfigurationError):
        return CONFIGURATION_ERROR, str(exc)
    if isinstance(exc, CleverAgentsError):
        return INTERNAL_ERROR, str(exc)  # ← A2aOperationNotFoundError falls here → -32603
    return INTERNAL_ERROR, str(exc)      # ← A2aVersionMismatchError falls here → -32603

Both A2aOperationNotFoundError and A2aVersionMismatchError extend A2aErrorCleverAgentsError, so they fall through to INTERNAL_ERROR (-32603) instead of returning their correct codes (-32601 and -32007 respectively).

Impact

  • Unknown method calls return error code -32603 (Internal Error) instead of -32601 (Method Not Found)
  • Version mismatch errors return -32603 instead of -32007 (Version Mismatch)
  • Clients cannot distinguish "method not found" from "internal server error"

Code Location

  • src/cleveragents/a2a/errors.pymap_domain_error() function (lines 120–162)
  • Missing constants: METHOD_NOT_FOUND = -32601 and VERSION_MISMATCH = -32007

Fix Required

  1. Add missing constants:
METHOD_NOT_FOUND: int = -32601
VERSION_MISMATCH: int = -32007
  1. Add cases to map_domain_error() before the CleverAgentsError catch-all:
if isinstance(exc, A2aOperationNotFoundError):
    return METHOD_NOT_FOUND, str(exc)
if isinstance(exc, A2aVersionMismatchError):
    return VERSION_MISMATCH, str(exc)

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

## Bug Report **Feature Area:** A2A Protocol — error code mapping **Severity:** Medium — incorrect JSON-RPC 2.0 error codes returned for method-not-found and version-mismatch errors --- ### What Was Tested Code-level analysis of `src/cleveragents/a2a/errors.py` — the `map_domain_error()` function and error code constants. ### Expected Behavior (from spec) Per ADR-047 (A2A Standard Adoption), the error code taxonomy maps: | Code | Meaning | Domain Exception | |------|---------|-----------------| | `-32601` | Method not found | `A2aOperationNotFoundError` | | `-32007` | Version mismatch | `A2aVersionMismatchError` | The `map_domain_error()` function is the canonical mapping from domain exceptions to JSON-RPC 2.0 error codes. It should handle all A2A-specific exceptions. ### Actual Behavior **File:** `src/cleveragents/a2a/errors.py` **Missing constants:** ```python # Defined in comments but NOT as constants: # -32601 Method not found ← no METHOD_NOT_FOUND constant # -32007 Version mismatch ← no VERSION_MISMATCH constant ``` **`map_domain_error()` missing cases:** ```python def map_domain_error(exc: Exception) -> tuple[int, str]: if isinstance(exc, ResourceNotFoundError): return NOT_FOUND, str(exc) if isinstance(exc, ValidationError): return VALIDATION_ERROR, str(exc) if isinstance(exc, PlanError): return PLAN_ERROR, str(exc) if isinstance(exc, BusinessRuleViolation): return INVALID_STATE, str(exc) if isinstance(exc, AuthenticationError): return AUTH_ERROR, str(exc) if isinstance(exc, AuthorizationError): return FORBIDDEN, str(exc) if isinstance(exc, ConfigurationError): return CONFIGURATION_ERROR, str(exc) if isinstance(exc, CleverAgentsError): return INTERNAL_ERROR, str(exc) # ← A2aOperationNotFoundError falls here → -32603 return INTERNAL_ERROR, str(exc) # ← A2aVersionMismatchError falls here → -32603 ``` Both `A2aOperationNotFoundError` and `A2aVersionMismatchError` extend `A2aError` → `CleverAgentsError`, so they fall through to `INTERNAL_ERROR` (-32603) instead of returning their correct codes (-32601 and -32007 respectively). ### Impact - Unknown method calls return error code -32603 (Internal Error) instead of -32601 (Method Not Found) - Version mismatch errors return -32603 instead of -32007 (Version Mismatch) - Clients cannot distinguish "method not found" from "internal server error" ### Code Location - `src/cleveragents/a2a/errors.py` — `map_domain_error()` function (lines 120–162) - Missing constants: `METHOD_NOT_FOUND = -32601` and `VERSION_MISMATCH = -32007` ### Fix Required 1. Add missing constants: ```python METHOD_NOT_FOUND: int = -32601 VERSION_MISMATCH: int = -32007 ``` 2. Add cases to `map_domain_error()` before the `CleverAgentsError` catch-all: ```python if isinstance(exc, A2aOperationNotFoundError): return METHOD_NOT_FOUND, str(exc) if isinstance(exc, A2aVersionMismatchError): return VERSION_MISMATCH, str(exc) ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 01:11:04 +00:00
Author
Owner

Issue triaged by project owner: Verified as valid spec compliance bug. Priority: Medium. Milestone: v3.2.0.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: Verified as valid spec compliance bug. Priority: Medium. Milestone: v3.2.0. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 modified the milestone from v3.2.0 to v3.5.0 2026-04-09 01:11:42 +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.

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