Skip to content

[Bug]: v0.3 gRPC client discards ErrorInfo metadata and BadRequest field violations #1521

In review

Description

@stanGSA

What happened?

PR #1503 updated _map_grpc_error in src/a2a/client/transports/grpc.py so the v1 gRPC client preserves a2a-protocol.org google.rpc.ErrorInfo.metadata and google.rpc.BadRequest field violations in A2AError.data.

In the v0.3 compatibility gRPC client, _map_grpc_error in src/a2a/compat/v0_3/grpc_transport.py#L63-L72 maps errors from ErrorInfo.reason (#1466), but discards ErrorInfo.metadata and ignores BadRequest details, raising the exception with data=None. Callers talking to a v0.3 gRPC peer that returns structured error metadata (such as metadata={"taskId": "job-1"}) or validation violations receive exc.data is None.

Expected behavior

When CompatGrpcTransport maps an error through ErrorInfo.reason, it should preserve structured details in A2AError.data following #1503:

  • ErrorInfo.metadata from domain == "a2a-protocol.org" is exposed in exc.data.
  • BadRequest field violations are exposed under exc.data["errors"] without being overwritten by an "errors" key in ErrorInfo.metadata, regardless of status.details order.
  • Foreign-domain ErrorInfo metadata is excluded.
  • Empty metadata without BadRequest still yields exc.data is None.
  • Existing "ClassName: message" error mapping keeps its current precedence and behavior.

Minimal reproduction

import grpc
from google.protobuf import any_pb2
from google.rpc import error_details_pb2, status_pb2

from a2a.client.transports.grpc import _map_grpc_error as v1_map
from a2a.compat.v0_3.grpc_transport import _map_grpc_error as v03_map

status = status_pb2.Status(
    code=grpc.StatusCode.NOT_FOUND.value[0], message='task missing'
)
detail = any_pb2.Any()
detail.Pack(
    error_details_pb2.ErrorInfo(
        reason='TASK_NOT_FOUND',
        domain='a2a-protocol.org',
        metadata={'taskId': 'job-1'},
    )
)
status.details.append(detail)

err = grpc.aio.AioRpcError(
    code=grpc.StatusCode.NOT_FOUND,
    initial_metadata=grpc.aio.Metadata(),
    trailing_metadata=grpc.aio.Metadata(
        ('grpc-status-details-bin', status.SerializeToString())
    ),
    details='task missing',
)

for name, fn in [
    ('v1   grpc._map_grpc_error', v1_map),
    ('v0.3 grpc_transport._map_grpc_error', v03_map),
]:
    try:
        fn(err)
    except Exception as exc:
        print(name, repr(exc))

Relevant log output

v1   grpc._map_grpc_error TaskNotFoundError(message='task missing', data={'taskId': 'job-1'})
v0.3 grpc_transport._map_grpc_error TaskNotFoundError(message='task missing', data=None)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    component: client
    on Nov 26, 2026
  2. added theissue type on Nov 26, 2026
  3. rohityan commented on Nov 26, 2026

    @rohityan

    Hi @stanGSA,

    Thanks for reporting this and for opening PR #1522. I was able to reproduce the error.

    When CompatGrpcTransport receives a grpc.aio.AioRpcError, _handle_grpc_exception() delegates to _map_grpc_error(). Unlike the v1 gRPC client's _map_grpc_error(), updated in PR #1503 , the v0.3 compatibility implementation immediately raises exception_cls(status.message) upon matching ErrorInfo.reason (added in PR #1466 without collecting a2a-protocol.org ErrorInfo.metadata or BadRequest field violations into A2AError.data.

    Your approach to solve this via PR #1522 appears to be correct. Assigning this issue to you until the PR is reviewed.

  4. stanGSA commented on Nov 26, 2026

    @stanGSA
    Author

    Thanks @rohityan for reproducing this and assigning the issue! PR #1522 is ready for review whenever a maintainer has time.

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

Metadata

Metadata

Assignees

Labels

component: clientstatus:awaiting response

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions