fix: Updating error payloads after the transcoding changes correction.#783
fix: Updating error payloads after the transcoding changes correction.#783ehsavoie wants to merge 1 commit intoa2aproject:mainfrom
Conversation
* Following the changes from a2aproject/A2A#1627 * Updating HTTP error codes. * Ensuring JSONRPC uses data for error details. Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
There was a problem hiding this comment.
Code Review
This pull request updates the A2A protocol error handling by renaming the 'details' field to 'data' in JSON-RPC responses and standardizing HTTP status codes across the transport layers using the A2AErrorCodes enum. It also adjusts gRPC error mappings and updates corresponding test cases to reflect these changes. The review feedback suggests further improving consistency in RestHandler.java by replacing remaining hardcoded HTTP status codes with enum references and reverting unnecessary formatting changes to records and annotations.
| private @Nullable | ||
| Instance<AgentCard> extendedAgentCard; |
| @@ -766,29 +766,38 @@ private static int mapErrorToHttpStatus(A2AError error) { | |||
| if (error instanceof InvalidParamsError) { | |||
| return 422; | |||
There was a problem hiding this comment.
For consistency with the rest of the method and to ensure that HTTP status codes are centralized in the A2AErrorCodes enum, please use A2AErrorCodes.INVALID_PARAMS.httpCode() instead of a hardcoded literal. This ensures adherence to the A2A protocol specification.
| return 422; | |
| return A2AErrorCodes.INVALID_PARAMS.httpCode(); |
References
- Adhere to the A2A protocol specification for error code mappings and move constants used across multiple modules to a shared location to ensure consistency.
| return 500; | ||
| return A2AErrorCodes.INTERNAL.httpCode(); | ||
| } | ||
| return 500; |
There was a problem hiding this comment.
It is better to use the centralized A2AErrorCodes.INTERNAL.httpCode() as the default return value to ensure consistency across the transport layer and adherence to the A2A protocol specification.
| return 500; | |
| return A2AErrorCodes.INTERNAL.httpCode(); |
References
- Adhere to the A2A protocol specification for error code mappings and move constants used across multiple modules to a shared location to ensure consistency.
| private record ErrorBody(int code, String status, String message, List<ErrorDetail> details) { | ||
|
|
||
| } | ||
|
|
||
| private record ErrorDetail( | ||
| @com.google.gson.annotations.SerializedName("@type") String type, | ||
| String reason, | ||
| String domain, | ||
| Map<String, Object> metadata) {} | ||
| Map<String, Object> metadata) { | ||
|
|
||
| } |
There was a problem hiding this comment.
These records were previously defined as concise one-liners. The addition of empty lines inside the record bodies is unnecessary and deviates from the project's style for simple data carriers.
private record ErrorBody(int code, String status, String message, List<ErrorDetail> details) {}
private record ErrorDetail(
@com.google.gson.annotations.SerializedName("@type") String type,
String reason,
String domain,
Map<String, Object> metadata) {}
Fixes #<issue_number_goes_here> 🦕