Repository navigation
fix(rest): fall back to the HTTP error when an error body field is not a string - #1343
Merged
ehsavoie merged 1 commit intoNov 20, 2026
Conversation
…t a string RestErrorMapper called getAsString() on the message, error and reason fields of an error body. A JSON null or a non-primitive value made it throw UnsupportedOperationException, which escaped RestTransport instead of the A2AClientException that carries the HTTP status and headers. Read these fields only when they are JSON primitives and otherwise treat them as absent, so such responses map to an A2AClientHTTPError. Fixes a2aproject#1342
ehsavoie
approved these changes
Nov 20, 2026
Collaborator
|
Thanks @sumitvairagar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1342.
RestErrorMappercalledgetAsString()on themessage,errorandreasonfields of an error body. When a field was JSONnullor an object, this threwUnsupportedOperationException. That exception escapedRestTransport, instead of theA2AClientExceptionthat carries the HTTP status and headers.The mapper now reads these fields only when they are JSON primitives, and otherwise treats them as absent, so such responses map to an
A2AClientHTTPError. Well-formed error bodies are handled as before. This mirrors #858, which fixed the same problem for the JSON-RPC error field.Tests: four regression tests in
RestErrorMapperTest, for a nullmessage, a non-stringmessage, a nullerror, and a nullreasonindetails. All four fail onmainand pass with this change. The REST transport module's tests pass.