Repository navigation
Description
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.metadatafromdomain == "a2a-protocol.org"is exposed inexc.data.BadRequestfield violations are exposed underexc.data["errors"]without being overwritten by an"errors"key inErrorInfo.metadata, regardless ofstatus.detailsorder.- Foreign-domain
ErrorInfometadata is excluded. - Empty metadata without
BadRequeststill yieldsexc.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
rohityan commentedon Nov 26, 2026
Hi @stanGSA,
Thanks for reporting this and for opening PR #1522. I was able to reproduce the error.
When
CompatGrpcTransportreceives agrpc.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 raisesexception_cls(status.message)upon matchingErrorInfo.reason(added in PR #1466 without collectinga2a-protocol.orgErrorInfo.metadataorBadRequestfield violations intoA2AError.data.Your approach to solve this via PR #1522 appears to be correct. Assigning this issue to you until the PR is reviewed.
stanGSA commentedon Nov 26, 2026
Thanks @rohityan for reproducing this and assigning the issue! PR #1522 is ready for review whenever a maintainer has time.