feat(errors): add structured error codes and details to A2A error types#743
feat(errors): add structured error codes and details to A2A error types#743ehsavoie wants to merge 1 commit intoa2aproject:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the error handling mechanisms across gRPC and REST transports by introducing a structured error system. By moving away from string-based error identification to explicit error codes and a detailed context map, the changes aim to provide more consistent, machine-readable, and robust error information. This improvement will streamline debugging, facilitate better error-driven logic, and ensure greater interoperability within the A2A protocol. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable refactoring of the error handling mechanism across gRPC and REST transports. The move from brittle string-matching on error descriptions to a structured approach using A2AErrorCodes and a details map is a major improvement for robustness and maintainability. The introduction of the A2AErrorCodes enum and the adoption of standard error formats (Google Cloud API for REST and ErrorInfo for gRPC) are excellent changes.
The refactoring has been applied consistently across the codebase, including the specification classes, transport handlers, and utility classes. The tests have also been thoroughly updated to reflect and validate the new structured error handling.
I've found a potential bug in the fallback error mapping in GrpcErrorMapper that could lead to a NullPointerException, and a couple of minor improvements in JSONRPCUtils regarding Gson instance reuse, which also align with project rules on consistency. Please see the detailed comments.
Overall, this is a high-quality contribution that greatly improves the project's error handling infrastructure.
client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a significant and valuable refactoring of the error handling mechanism, moving from brittle string-matching to a structured, code-based approach. The introduction of A2AErrorCodes, the use of google.rpc.ErrorInfo in gRPC, and the adoption of a consistent Google Cloud API-style error format for REST are all excellent improvements that will enhance the robustness and maintainability of the error handling logic. My review focuses on a few areas where the new implementation could be made even more robust by ensuring the new structured error details are fully preserved across the transport layer and that error codes are mapped with appropriate specificity.
client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java
Outdated
Show resolved
Hide resolved
client/transport/rest/src/main/java/io/a2a/client/transport/rest/RestErrorMapper.java
Outdated
Show resolved
Hide resolved
client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java
Outdated
Show resolved
Hide resolved
transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcHandler.java
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a significant and valuable feature enhancement that refactors error handling across the A2A protocol. The move from brittle string-matching to a structured approach using the A2AErrorCodes enum and a details map is a major improvement for robustness and maintainability. Aligning gRPC and REST error responses with standard formats like ErrorInfo and the Google Cloud API error model is also a great step forward. The changes are consistently applied, and the tests are well-updated to reflect the new error handling mechanism. I've identified one critical issue in the GrpcErrorMapper that appears to be a compilation error due to a generics type mismatch, which I've detailed in a specific comment.
client/transport/grpc/src/main/java/io/a2a/client/transport/grpc/GrpcErrorMapper.java
Outdated
Show resolved
Hide resolved
Replace brittle string-matching error detection in gRPC and REST transports with a structured approach using error codes (A2AErrorCodes) and a details field. The GrpcErrorMapper now extracts ErrorInfo from gRPC status details via a REASON_MAP lookup, and error types carry richer context through a dedicated details field. Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Replace brittle string-matching error detection in gRPC and REST transports with a structured approach using error codes (A2AErrorCodes) and a details field. The GrpcErrorMapper now extracts ErrorInfo from gRPC status details via a REASON_MAP lookup, and error types carry richer context through a dedicated details field.
🦕