feat(rest): update REST error handling to use google.rpc.Status#838
feat(rest): update REST error handling to use google.rpc.Status#838
google.rpc.Status#838Conversation
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 robustness and consistency of error handling within the A2A REST API ecosystem. By adopting the AIP-193 standard for error responses, both server-side and client-side components now communicate errors in a unified, machine-readable format. This change improves interoperability, simplifies error diagnosis, and provides a clearer contract for how errors are structured and interpreted across the platform. Highlights
Changelog
Activity
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 is an excellent refactoring of the REST error handling to conform to the AIP-193 google.rpc.Status standard. The changes are comprehensive, touching the client, server, and utility code to ensure consistency. The introduction of A2A_REST_ERROR_MAPPING centralizes error information, greatly improving maintainability. The server-side exception handlers are now standardized, and the client is updated to parse the new error format. The accompanying tests are thorough and correctly validate the new behavior. I have one minor suggestion to improve the consistency of logging.
|
@check-spelling-bot apply updates |
|
I am afraid #838 (comment) doesn't work, we usually just add unknown words to |
2438832 to
27624a2
Compare
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/transports/rest.py | 92.41% | 91.52% | 🔴 -0.90% |
| src/a2a/server/apps/rest/fastapi_app.py | 80.95% | 81.25% | 🟢 +0.30% |
| src/a2a/utils/error_handlers.py | 91.67% | 93.33% | 🟢 +1.67% |
| Total | 89.94% | 89.94% | ⚪️ 0.00% |
Generated by coverage-comment.yml
5253607 to
5889fed
Compare
google.rpc.Status
- Refactor mapping to use a namedtuple for RestErrorMap - Extract _build_error_payload helper function for error responses - Fix truthiness check for error data in logs

Description
This PR refactors the REST transport error handling to adhere to the
google.rpc.StatusJSON format. Both the server-side exception handlers and the client-side REST transport have been updated to utilize the new standard error envelope, ensuring consistency across A2A REST APIs.Summary of Changes
rest_error_handlerand the globalStarletteHTTPExceptionhandler inA2ARESTFastAPIApplicationto return errors wrapped in an{'error': {...}}envelope.code, gRPCstatus,message, and adetailsarray containingtype.googleapis.com/google.rpc.ErrorInfofor the specific reason and metadata.RestTransport._handle_http_errorto parse the new format. It now gracefully extracts thereasonfrom theErrorInfodetail object to map it back to the corresponding PythonA2AErrorclass.A2A_REST_ERROR_MAPPINGinerrors.pyto centralize the mapping of Python exceptions to their respective HTTP status codes, gRPC statuses, and string reasons.dataattribute to the baseA2AErrorto carry arbitrary error metadata.{'error': {...}}JSON payload structures.CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.bash scripts/format.shfrom the repository root to format)Fixes #722 🦕