Skip to content

fix(a2a-grpc): preserve precise A2A error codes - #114

Merged
msardara merged 2 commits into
a2aproject:mainfrom
jstar0:fix/grpc-error-info
Jul 27, 2026
Merged

fix(a2a-grpc): preserve precise A2A error codes#114
msardara merged 2 commits into
a2aproject:mainfrom
jstar0:fix/grpc-error-info

Conversation

@jstar0

@jstar0 jstar0 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

The gRPC boundary currently maps errors using only tonic::Code. Six distinct
A2A errors share FAILED_PRECONDITION, so clients decode all of them as
TaskNotCancelable. The server conversion also omits the
google.rpc.ErrorInfo detail that other SDKs need to recover the precise A2A
reason.

Changes

  • Emit an AIP-193 ErrorInfo with the existing A2A reason and
    a2a-protocol.org domain from the server conversion.
  • Decode only known reasons from that protocol domain on the client conversion.
  • Preserve string metadata from existing ErrorInfo details and field
    violations from existing BadRequest details when constructing the gRPC
    status.
  • Keep the current gRPC-code fallback for peers that omit details or send
    malformed, unknown, or foreign-domain details.
  • Cover all six FAILED_PRECONDITION mappings in both directions, including an
    independently constructed peer status, and cover all four
    INVALID_ARGUMENT reasons plus structured detail propagation.

This uses tonic-types, the official rich error model companion for the
workspace's existing Tonic 0.14 dependency.

Compatibility

The gRPC status codes and messages are unchanged. Existing peers without rich
details continue to use the previous fallback behavior. Malformed detail
entries are ignored rather than changing status conversion.

Verification

cargo test -p a2a-grpc errors
cargo hack check --workspace --all-targets --each-feature
cargo fmt --all -- --check
cargo hack clippy --workspace --all-targets --each-feature -- -D warnings
cargo test --workspace

Fixes #103

Encode A2A error reasons as google.rpc.ErrorInfo details and recover trusted protocol reasons on the client. Keep the existing gRPC-code fallback for missing or invalid details.

Fixes: a2aproject#103
Signed-off-by: King Star <mcxin.y@gmail.com>
@jstar0
jstar0 requested a review from a team as a code owner July 26, 2026 01:31

@msardara msardara left a comment

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.

Thanks for the PR @jstar0! PR looks good, but I added some comments regarding some information we potentially miss when constructing the grpc status.

Comment thread a2a-grpc/src/errors.rs
Comment thread a2a-grpc/src/errors.rs Outdated
Forward ErrorInfo metadata and BadRequest field violations when converting A2A errors to gRPC status details. Cover every InvalidArgument protocol reason.

Refs: a2aproject#103
Signed-off-by: King Star <mcxin.y@gmail.com>
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.31973% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
a2a-grpc/src/errors.rs 99.31% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@msardara msardara left a comment

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.

LGTM, thanks @jstar0!

@msardara
msardara merged commit 94f4d32 into a2aproject:main Jul 27, 2026
10 checks passed
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.

gRPC client ignores google.rpc.Status/ErrorInfo, collapsing all FAILED_PRECONDITION errors to -32002 (TaskNotCancelable)

2 participants