A2A facade returns -32603 Internal error for missing/invalid params instead of -32602 Invalid params #6273

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

Summary

A2aLocalFacade.dispatch() reports JSON-RPC error code -32603 (Internal error) for every parameter validation failure. Handlers such as _handle_plan_status and _handle_plan_execute raise ValueError when a required argument is missing. map_domain_error() in src/cleveragents/a2a/errors.py does not special-case built-in ValueError, so these exceptions fall through to the catch-all branch that returns INTERNAL_ERROR (-32603). JSON-RPC clients therefore see what looks like a server-side failure instead of an Invalid params fault.

Steps to Reproduce

  1. Instantiate an A2aLocalFacade (no services required).
  2. Dispatch a request that omits a required parameter, e.g. facade.dispatch(A2aRequest(method="_cleveragents/plan/status", params={})).
  3. Inspect the returned A2aResponse.error.code.

Expected Result

Per JSON-RPC 2.0 §5.1, missing/invalid parameters must produce error code -32602 (Invalid params). The platform already defines VALIDATION_ERROR = -32602 in errors.py for this purpose.

Actual Result

map_domain_error(ValueError(...)) falls through to the default branch and returns -32603 (Internal error). Clients cannot distinguish user mistakes from real server faults.

Impact

All A2A operations that perform local validation (plan.status, plan.execute, _cleveragents/plan/*, etc.) misreport caller mistakes as server errors. Automated tooling cannot react correctly and human operators see noisy "Internal error" messages that mask the real problem.

Code References

  • src/cleveragents/a2a/facade.py lines 402-408, 386-393, 436-438: handlers raise ValueError for missing params.
  • src/cleveragents/a2a/errors.py lines 146-163: map_domain_error() never maps ValueError to VALIDATION_ERROR.

Suggested Fix

Extend map_domain_error() to treat builtin ValueError (and optionally TypeError) as VALIDATION_ERROR (-32602). Alternatively, the facade handlers could raise the project’s ValidationError, but adding a ValueError branch keeps the change localized.

## Summary `A2aLocalFacade.dispatch()` reports JSON-RPC error code `-32603` (Internal error) for every parameter validation failure. Handlers such as `_handle_plan_status` and `_handle_plan_execute` raise `ValueError` when a required argument is missing. `map_domain_error()` in `src/cleveragents/a2a/errors.py` does not special-case built-in `ValueError`, so these exceptions fall through to the catch-all branch that returns `INTERNAL_ERROR` (-32603). JSON-RPC clients therefore see what looks like a server-side failure instead of an `Invalid params` fault. ## Steps to Reproduce 1. Instantiate an `A2aLocalFacade` (no services required). 2. Dispatch a request that omits a required parameter, e.g. `facade.dispatch(A2aRequest(method="_cleveragents/plan/status", params={}))`. 3. Inspect the returned `A2aResponse.error.code`. ## Expected Result Per JSON-RPC 2.0 §5.1, missing/invalid parameters must produce error code **`-32602` (Invalid params)**. The platform already defines `VALIDATION_ERROR = -32602` in `errors.py` for this purpose. ## Actual Result `map_domain_error(ValueError(...))` falls through to the default branch and returns **`-32603` (Internal error)**. Clients cannot distinguish user mistakes from real server faults. ## Impact All A2A operations that perform local validation (`plan.status`, `plan.execute`, `_cleveragents/plan/*`, etc.) misreport caller mistakes as server errors. Automated tooling cannot react correctly and human operators see noisy "Internal error" messages that mask the real problem. ## Code References - `src/cleveragents/a2a/facade.py` lines 402-408, 386-393, 436-438: handlers raise `ValueError` for missing params. - `src/cleveragents/a2a/errors.py` lines 146-163: `map_domain_error()` never maps `ValueError` to `VALIDATION_ERROR`. ## Suggested Fix Extend `map_domain_error()` to treat builtin `ValueError` (and optionally `TypeError`) as `VALIDATION_ERROR` (-32602). Alternatively, the facade handlers could raise the project’s `ValidationError`, but adding a `ValueError` branch keeps the change localized.
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#6273
No description provided.