f5d244cd37
CI / lint (pull_request) Failing after 30s
CI / typecheck (pull_request) Successful in 51s
CI / quality (pull_request) Successful in 46s
CI / security (pull_request) Successful in 53s
CI / coverage (pull_request) Has been skipped
CI / helm (pull_request) Successful in 23s
CI / build (pull_request) Successful in 47s
CI / unit_tests (pull_request) Successful in 6m30s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 18m51s
CI / integration_tests (pull_request) Successful in 23m20s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
Per JSON-RPC 2.0 specification (Section 5.1), error codes must be integers.
This commit fixes the protocol compliance defect where A2aErrorDetail.code
was typed as str and error constants were string literals.
Changes:
- src/cleveragents/a2a/models.py: Change A2aErrorDetail.code from str to int;
update field_validator to only validate 'message' (code no longer needs
non-empty string check; Pydantic enforces int type)
- src/cleveragents/a2a/errors.py: Change all error code constants from string
literals to JSON-RPC 2.0 integer codes per docs/reference/a2a.md taxonomy:
NOT_FOUND = -32001, AUTH_ERROR = -32002, FORBIDDEN = -32003,
INVALID_STATE = -32004, PLAN_ERROR = -32008, CONFIGURATION_ERROR = -32009,
VALIDATION_ERROR = -32602, INTERNAL_ERROR = -32603
Update map_domain_error() return type from tuple[str, str] to tuple[int, str]
- features/steps/a2a_facade_steps.py: Update A2aErrorDetail construction to
map symbolic string names to integer codes via _CODE_MAP
- features/steps/a2a_facade_wiring_steps.py: Update error code assertion to
map symbolic names to integers for comparison
- features/steps/a2a_facade_coverage_boost_steps.py: Same as above
- features/steps/a2a_jsonrpc_wire_format_steps.py: Update all A2aErrorDetail
constructions and JSON-RPC dict payloads to use integer codes
- robot/helper_a2a_facade_wiring.py: Update wired_error_mapping() to compare
against integer codes
- robot/helper_a2a_jsonrpc_wire_format.py: Update response_error_wire_format()
to use integer code -32001 instead of string 'NOT_FOUND'
Wire format now produces {"code": -32001, ...} instead of {"code": "NOT_FOUND", ...},
making it compliant with JSON-RPC 2.0 and interoperable with standards-conformant clients.
ISSUES CLOSED: #2746
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""Shared A2A error code mapping for Behave step definitions.
|
|
|
|
Provides a single source of truth for the mapping between symbolic error
|
|
name strings (used in Gherkin feature files) and their corresponding
|
|
JSON-RPC 2.0 integer codes (defined in ``cleveragents.a2a.errors``).
|
|
|
|
All step files that need to translate a symbolic name like ``"NOT_FOUND"``
|
|
to its integer code ``-32001`` should import :data:`A2A_CODE_MAP` from
|
|
this module rather than defining a local ``_CODE_MAP`` dictionary.
|
|
|
|
This eliminates the DRY violation identified in code review where the
|
|
same mapping was duplicated across 4 step files (6 definitions total).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from cleveragents.a2a import errors as _a2a_errors
|
|
|
|
#: Maps symbolic error name strings (as used in Gherkin feature files) to
|
|
#: their JSON-RPC 2.0 integer error codes. Derived directly from the
|
|
#: ``cleveragents.a2a.errors`` module constants so that any future change
|
|
#: to the integer values is automatically reflected here.
|
|
A2A_CODE_MAP: dict[str, int] = {
|
|
"NOT_FOUND": _a2a_errors.NOT_FOUND,
|
|
"AUTH_ERROR": _a2a_errors.AUTH_ERROR,
|
|
"FORBIDDEN": _a2a_errors.FORBIDDEN,
|
|
"INVALID_STATE": _a2a_errors.INVALID_STATE,
|
|
"PLAN_ERROR": _a2a_errors.PLAN_ERROR,
|
|
"CONFIGURATION_ERROR": _a2a_errors.CONFIGURATION_ERROR,
|
|
"VALIDATION_ERROR": _a2a_errors.VALIDATION_ERROR,
|
|
"INTERNAL_ERROR": _a2a_errors.INTERNAL_ERROR,
|
|
}
|
|
|
|
__all__ = ["A2A_CODE_MAP"]
|