You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: RestErrorMapper throws UnsupportedOperationException when an error body has a null or non-string message #1342
RestErrorMapper.mapRestError assumes the message and error fields of an HTTP error body are JSON strings. When they are null or another JSON type, getAsString() throws UnsupportedOperationException. The method only catches JsonProcessingException, so the exception escapes every RestTransport call that gets a non-2xx response. The caller receives an unchecked exception instead of an A2AClientException, and the HTTP status and headers that A2AClientHTTPError would carry are lost.
A body like this can come from a proxy or gateway in front of the agent, for example:
{"error": {"code": 502, "message": null}}
The affected calls in RestErrorMapper.java on main (897835ef):
line 70: errorObj.get("message").getAsString() (Google-style {"error": {...}} format)
lines 85–86: node.get("error").getAsString() and node.get("message").getAsString() (legacy format)
line 116: detail.get("reason").getAsString() follows the same pattern
has("message") returns true when the value is JSON null, so the existing check does not prevent this.
Expected: an A2AClientException wrapping an A2AClientHTTPError with code 502, the same as for a non-JSON error body. Actual:java.lang.UnsupportedOperationException: JsonNull. A non-string message such as {"detail": "upstream down"} gives UnsupportedOperationException: JsonObject.
#858 fixed the same kind of problem for the JSON-RPC error field. I'd be happy to open a PR that reads these fields only when they are JSON strings and falls back to the HTTP status otherwise, with regression tests for each case.
Activity
fix(rest): fall back to the HTTP error when an error body field is no…