Skip to content

fix: Updating error payloads after the transcoding changes correction.#783

Open
ehsavoie wants to merge 1 commit intoa2aproject:mainfrom
ehsavoie:transcoding_errors
Open

fix: Updating error payloads after the transcoding changes correction.#783
ehsavoie wants to merge 1 commit intoa2aproject:mainfrom
ehsavoie:transcoding_errors

Conversation

@ehsavoie
Copy link
Copy Markdown
Collaborator

@ehsavoie ehsavoie commented Apr 8, 2026

Fixes #<issue_number_goes_here> 🦕

* 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>
@ehsavoie ehsavoie requested review from jmesnil and kabir April 8, 2026 09:11
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +130 to +131
private @Nullable
Instance<AgentCard> extendedAgentCard;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The @Nullable annotation should be on the same line as the field type to maintain consistent formatting and readability.

Suggested change
private @Nullable
Instance<AgentCard> extendedAgentCard;
private @Nullable Instance<AgentCard> extendedAgentCard;

@@ -766,29 +766,38 @@ private static int mapErrorToHttpStatus(A2AError error) {
if (error instanceof InvalidParamsError) {
return 422;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
return 422;
return A2AErrorCodes.INVALID_PARAMS.httpCode();
References
  1. 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
return 500;
return A2AErrorCodes.INTERNAL.httpCode();
References
  1. Adhere to the A2A protocol specification for error code mappings and move constants used across multiple modules to a shared location to ensure consistency.

Comment on lines +1048 to +1058
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) {

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant