Skip to content

[Bug]: grpc_handler maps 3 A2A errors to FAILED_PRECONDITION instead of UNIMPLEMENTED, and doesn't validate A2A-Version at all #1166

Closed as not planned

Description

@avilleroy51

What happened?

grpc_handler.py's _ERROR_CODE_MAP (src/a2a/server/request_handlers/grpc_handler.py:84-98) maps 3 of the 9 A2A error types to the wrong gRPC status code, diverging from the canonical binding table in the spec (specification.md "Custom Binding Requirements" / error-code-mappings section):

A2A Error Type Spec gRPC Status SDK gRPC Status
PushNotificationNotSupportedError UNIMPLEMENTED FAILED_PRECONDITION ❌
UnsupportedOperationError UNIMPLEMENTED FAILED_PRECONDITION ❌
VersionNotSupportedError UNIMPLEMENTED FAILED_PRECONDITION ❌
_ERROR_CODE_MAP: dict[type[A2AError], grpc.StatusCode] = {
    ...
    types.PushNotificationNotSupportedError: grpc.StatusCode.FAILED_PRECONDITION,
    types.UnsupportedOperationError: grpc.StatusCode.FAILED_PRECONDITION,
    ...
    types.VersionNotSupportedError: grpc.StatusCode.FAILED_PRECONDITION,
}

The other 6 mappings (TaskNotFoundError, TaskNotCancelableError, ContentTypeNotSupportedError, InvalidAgentResponseError, ExtendedAgentCardNotConfiguredError, ExtensionSupportRequiredError) are all correct against the same table.

Second, related bug: gRPC transport doesn't validate A2A-Version at all

jsonrpc_dispatcher.py and rest_dispatcher.py both guard their handlers with @validate_version(constants.PROTOCOL_VERSION_1_0), which raises VersionNotSupportedError for an unsupported A2A-Version. grpc_handler.py has no equivalent — a SendMessage gRPC call with metadata a2a-version: 99.0 is processed normally instead of being rejected. Per spec (specification.md:739): "Agents MUST process requests using the semantics of the requested A2A-Version... If the version is not supported by the interface, agents MUST return a VersionNotSupportedError."

Reproduction

Against a standard DefaultRequestHandlerV2-backed gRPC server:

import grpc
metadata = [("a2a-version", "99.0")]
client.stub.SendMessage(proto_request, metadata=metadata)
# succeeds — no VersionNotSupportedError, no version check at all

For the status-code mismatch, trigger any PushNotificationNotSupportedError (e.g. call CreatePushNotificationConfig when capabilities.push_notifications is false) over gRPC and inspect e.code() — it's FAILED_PRECONDITION, not UNIMPLEMENTED.

We hit both while running the official a2a-tck MUST-level gRPC suite against a reference SUT built on this SDK — GRPC-ERR-002 fails on test_push_not_supported_returns_unimplemented and test_version_not_supported_returns_unimplemented for exactly these reasons.

Expected

  • Fix the 3 entries in _ERROR_CODE_MAP to UNIMPLEMENTED, matching the other 6 and the spec table.
  • Apply the same version-validation the HTTP dispatchers already do to the gRPC transport (a @validate_version-equivalent, or an explicit check in GrpcHandler reading the a2a-version metadata key).

Happy to send a PR for both if useful.

Activity

  1. avilleroy51 commented on Aug 6, 2026

    @avilleroy51
    Author

    Fixed in #1167.

  2. added a commit that references this issue on Aug 6, 2026
    998b675
  3. self-assigned this
    on Aug 10, 2026
  4. added
    component: server
    on Aug 12, 2026
  5. added theissue type on Aug 12, 2026
  6. rohityan commented on Aug 12, 2026

    @rohityan

    Hi @avilleroy51 , Thank you for reporting this and contributing in #1167 to fix this. Your diagnosis of the issue is accurate.
    In your fix within _validate_a2a_version(), if a user supplies a custom GrpcServerCallContextBuilder that does not populate state['headers'], it currently defaults to '0.3' and would reject valid 1.0 requests. Consider adding a fallback to read invocation_metadata() directly from server_context.state.get('grpc_context') if headers is missing.
    Also could you add unit tests in test_grpc_handler.py explicitly asserting that an incompatible version (e.g. a2a-version: 99.0) or an absent version metadata properly triggers VersionNotSupportedError / StatusCode.UNIMPLEMENTED.
    Assigning this issue to you till the PR gets reviewed.

  7. mykytanetipa commented on Aug 20, 2026

    @mykytanetipa
    Collaborator

    Spec PR a2aproject/A2A#1627 merged 2026-04-14 and shipped in v1.0.1 reverted PushNotificationNotSupportedError, UnsupportedOperationError, and VersionNotSupportedError from UNIMPLEMENTED back to FAILED_PRECONDITION.

    Current spec shows FAILED_PRECONDITION for all three which is what grpc_handler._ERROR_CODE_MAP already has (please refer to the https://github.com/a2aproject/A2A/blob/v1.0.1/docs/specification.md). The UNIMPLEMENTED table you cited is the older v1.0.0 revision.

  8. github-actions commented on Sep 3, 2026

    @github-actions

    Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

  9. github-actions commented on Sep 16, 2026

    @github-actions

    This issue was closed because it has been inactive for 27 days. Please post a new issue if you need further assistance. Thanks!

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

Metadata

Metadata

Assignees

Labels

component: serverstatus:awaiting responsestatus:stale

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions