UAT: A2aErrorDetail.code is typed as str — JSON-RPC 2.0 requires error codes to be integers #2563

Closed
opened 2026-04-03 18:54:39 +00:00 by freemo · 1 comment
Owner

Bug Report

Feature Area

Standards Alignment — JSON-RPC 2.0 / A2A Protocol

What Was Tested

Code-level analysis of src/cleveragents/a2a/models.py — the A2aErrorDetail model that represents the JSON-RPC 2.0 error object.

Expected Behavior (from spec)

The JSON-RPC 2.0 specification (§5.1) defines the error object as:

{"code": <integer>, "message": <string>, "data": <any>}

The code field must be an integer. The spec defines standard codes:

  • -32700 Parse error
  • -32600 Invalid Request
  • -32601 Method not found
  • -32602 Invalid params
  • -32603 Internal error
  • -32000 to -32099 Server error (reserved)

The A2A protocol inherits this from JSON-RPC 2.0.

Actual Behavior (from code)

In src/cleveragents/a2a/models.py (line 69):

class A2aErrorDetail(BaseModel):
    code: str          # ← WRONG: should be int
    message: str
    details: dict[str, Any] = {}

The code field is typed as str. The error codes defined in src/cleveragents/a2a/errors.py are all strings:

NOT_FOUND: str = "NOT_FOUND"
VALIDATION_ERROR: str = "VALIDATION_ERROR"
INVALID_STATE: str = "INVALID_STATE"
PLAN_ERROR: str = "PLAN_ERROR"
AUTH_ERROR: str = "AUTH_ERROR"
FORBIDDEN: str = "FORBIDDEN"
CONFIGURATION_ERROR: str = "CONFIGURATION_ERROR"
INTERNAL_ERROR: str = "INTERNAL_ERROR"

This means any JSON-RPC 2.0 compliant client parsing the error response will fail because it expects an integer code, not a string like "NOT_FOUND".

Impact

  • Protocol non-compliance: Any standard JSON-RPC 2.0 or A2A client will reject error responses from CleverAgents.
  • Interoperability broken: Third-party A2A clients cannot parse CleverAgents error responses.
  • LSP server also affected: src/cleveragents/lsp/server.py correctly uses integer codes (-32700, -32601, etc.) but the A2A layer uses strings.

Code Location

  • src/cleveragents/a2a/models.pyA2aErrorDetail.code: str (line 69)
  • src/cleveragents/a2a/errors.py — all error code constants are str type

Steps to Reproduce

from cleveragents.a2a.models import A2aErrorDetail
err = A2aErrorDetail(code="NOT_FOUND", message="Resource not found")
import json
print(json.dumps(err.model_dump()))
# Output: {"code": "NOT_FOUND", "message": "Resource not found", "details": {}}
# Expected per JSON-RPC 2.0: {"code": -32001, "message": "Resource not found"}

Fix Required

  1. Change A2aErrorDetail.code from str to int.
  2. Replace string error code constants in errors.py with integer values in the JSON-RPC 2.0 server error range (-32000 to -32099), e.g.:
    • NOT_FOUND = -32001
    • VALIDATION_ERROR = -32002
    • etc.
  3. Update map_domain_error() to return (int, str) tuples.

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

## Bug Report ### Feature Area Standards Alignment — JSON-RPC 2.0 / A2A Protocol ### What Was Tested Code-level analysis of `src/cleveragents/a2a/models.py` — the `A2aErrorDetail` model that represents the JSON-RPC 2.0 error object. ### Expected Behavior (from spec) The JSON-RPC 2.0 specification (§5.1) defines the error object as: ```json {"code": <integer>, "message": <string>, "data": <any>} ``` The `code` field **must be an integer**. The spec defines standard codes: - `-32700` Parse error - `-32600` Invalid Request - `-32601` Method not found - `-32602` Invalid params - `-32603` Internal error - `-32000` to `-32099` Server error (reserved) The A2A protocol inherits this from JSON-RPC 2.0. ### Actual Behavior (from code) In `src/cleveragents/a2a/models.py` (line 69): ```python class A2aErrorDetail(BaseModel): code: str # ← WRONG: should be int message: str details: dict[str, Any] = {} ``` The `code` field is typed as `str`. The error codes defined in `src/cleveragents/a2a/errors.py` are all strings: ```python NOT_FOUND: str = "NOT_FOUND" VALIDATION_ERROR: str = "VALIDATION_ERROR" INVALID_STATE: str = "INVALID_STATE" PLAN_ERROR: str = "PLAN_ERROR" AUTH_ERROR: str = "AUTH_ERROR" FORBIDDEN: str = "FORBIDDEN" CONFIGURATION_ERROR: str = "CONFIGURATION_ERROR" INTERNAL_ERROR: str = "INTERNAL_ERROR" ``` This means any JSON-RPC 2.0 compliant client parsing the error response will fail because it expects an integer `code`, not a string like `"NOT_FOUND"`. ### Impact - **Protocol non-compliance**: Any standard JSON-RPC 2.0 or A2A client will reject error responses from CleverAgents. - **Interoperability broken**: Third-party A2A clients cannot parse CleverAgents error responses. - **LSP server also affected**: `src/cleveragents/lsp/server.py` correctly uses integer codes (`-32700`, `-32601`, etc.) but the A2A layer uses strings. ### Code Location - `src/cleveragents/a2a/models.py` — `A2aErrorDetail.code: str` (line 69) - `src/cleveragents/a2a/errors.py` — all error code constants are `str` type ### Steps to Reproduce ```python from cleveragents.a2a.models import A2aErrorDetail err = A2aErrorDetail(code="NOT_FOUND", message="Resource not found") import json print(json.dumps(err.model_dump())) # Output: {"code": "NOT_FOUND", "message": "Resource not found", "details": {}} # Expected per JSON-RPC 2.0: {"code": -32001, "message": "Resource not found"} ``` ### Fix Required 1. Change `A2aErrorDetail.code` from `str` to `int`. 2. Replace string error code constants in `errors.py` with integer values in the JSON-RPC 2.0 server error range (`-32000` to `-32099`), e.g.: - `NOT_FOUND = -32001` - `VALIDATION_ERROR = -32002` - etc. 3. Update `map_domain_error()` to return `(int, str)` tuples. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Closing as duplicate of #2462. Both issues describe the same bug: A2aErrorDetail.code is typed as str but JSON-RPC 2.0 requires integer error codes. Issue #2462 was filed first.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Closing as duplicate of #2462. Both issues describe the same bug: `A2aErrorDetail.code` is typed as `str` but JSON-RPC 2.0 requires integer error codes. Issue #2462 was filed first. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
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#2563
No description provided.