Skip to content

fix: Include google.rpc.ErrorInfo in gRPC error status details#738

Open
kabir wants to merge 2 commits intoa2aproject:mainfrom
kabir:issue-731-grpc-errorinfo
Open

fix: Include google.rpc.ErrorInfo in gRPC error status details#738
kabir wants to merge 2 commits intoa2aproject:mainfrom
kabir:issue-731-grpc-errorinfo

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Mar 12, 2026

Per specification requirement GRPC-ERR-001 (section 10.6), A2A-specific errors must include a google.rpc.ErrorInfo message in the status.details array with:

  • reason: A2A error type in UPPER_SNAKE_CASE without "Error" suffix
  • domain: "a2a-protocol.org"
  • metadata: Optional map of additional error context

Modified GrpcHandler.handleError() to:

  1. Create google.rpc.ErrorInfo with appropriate reason and domain
  2. Build google.rpc.Status containing the ErrorInfo in details
  3. Include Status in grpc-status-details-bin trailing metadata
  4. Rename ExtendedCardNotConfiguredError to ExtendedAgentCardNotConfiguredError. This wasn't part of the original work done in this PR, but was picked up by the Gemini review, so I included it

This ensures gRPC error responses comply with the A2A specification by providing structured error information that clients can programmatically inspect and handle.

Fixes #731

Per specification requirement GRPC-ERR-001 (section 10.6), A2A-specific
errors must include a google.rpc.ErrorInfo message in the status.details
array with:
- reason: A2A error type in UPPER_SNAKE_CASE without "Error" suffix
- domain: "a2a-protocol.org"
- metadata: Optional map of additional error context

Modified GrpcHandler.handleError() to:
1. Create google.rpc.ErrorInfo with appropriate reason and domain
2. Build google.rpc.Status containing the ErrorInfo in details
3. Include Status in grpc-status-details-bin trailing metadata

This ensures gRPC error responses comply with the A2A specification
by providing structured error information that clients can programmatically
inspect and handle.

Fixes a2aproject#731

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the gRPC error handling mechanism to align with the A2A specification. By embedding structured error details, specifically google.rpc.ErrorInfo, into gRPC responses, clients can now programmatically parse and react to specific error types, improving the robustness and interoperability of the A2A protocol.

Highlights

  • gRPC Error Specification Compliance: Implemented GRPC-ERR-001 (section 10.6) specification requirement to include google.rpc.ErrorInfo in gRPC error status details for A2A-specific errors.
  • Structured Error Information: Modified GrpcHandler.handleError() to construct and embed google.rpc.ErrorInfo messages within the status.details array of google.rpc.Status objects.
  • Metadata Inclusion: Ensured the google.rpc.Status object, containing the ErrorInfo, is included in the grpc-status-details-bin trailing metadata of gRPC error responses.
  • Error Reason Mapping: Mapped various A2AError types to specific UPPER_SNAKE_CASE reason strings (e.g., INVALID_REQUEST, METHOD_NOT_FOUND) for the ErrorInfo.
Changelog
  • transport/grpc/src/main/java/io/a2a/transport/grpc/handler/GrpcHandler.java
    • Introduced an errorReason variable to categorize different A2AError types.
    • Assigned specific UPPER_SNAKE_CASE reason strings to errorReason based on the type of A2AError.
    • Constructed a com.google.rpc.ErrorInfo object using the determined errorReason and a fixed domain of "a2a-protocol.org".
    • Built a com.google.rpc.Status object, incorporating the original gRPC status code and description, and adding the ErrorInfo to its details.
    • Created io.grpc.Metadata trailers and populated them with the com.google.rpc.Status object under the grpc-status-details-bin key.
    • Modified the responseObserver.onError call to pass these newly constructed trailers, ensuring structured error details are sent to the client.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 correctly implements the specification requirement to include google.rpc.ErrorInfo in gRPC error status details for A2A-specific errors. The changes in GrpcHandler.handleError properly construct the ErrorInfo and attach it to the response metadata. I've added a couple of suggestions to improve code maintainability and performance within the modified handleError method.

@jmesnil jmesnil added the hold label Mar 13, 2026
@jmesnil
Copy link
Collaborator

jmesnil commented Mar 13, 2026

@kabir I have a look at the v1.0.0 spec and they changed that part in a2aproject/A2A#1600. We will have to revisit it, #731 is now out of date

@jmesnil jmesnil self-requested a review March 13, 2026 07:47
@ehsavoie
Copy link
Collaborator

Shouldn't we handle this at the A2AError level ?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gRPC errors do not include google.rpc.ErrorInfo

3 participants