fix: validate A2A version and extensions on all gRPC handler methods - #1042
Open
ez-lbz wants to merge 1 commit into
Open
fix: validate A2A version and extensions on all gRPC handler methods#1042ez-lbz wants to merge 1 commit into
ez-lbz wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
1. Enforce A2A version and extension validation on all gRPC handler methods
Problem: In
GrpcHandler, onlysendMessageandsendStreamingMessagecalledA2AVersionValidator.validateProtocolVersion+A2AExtensions.validateRequiredExtensions. The remaining methods —getTask,listTasks,cancelTask,createTaskPushNotificationConfig,getTaskPushNotificationConfig,listTaskPushNotificationConfigs,subscribeToTask,deleteTaskPushNotificationConfig,getExtendedAgentCard— skipped validation entirely, so clients using an incompatible protocol version (or missing required extensions) were served instead of being rejected.Fix (transport/grpc/src/main/java/org/a2aproject/sdk/transport/grpc/handler/GrpcHandler.java):
A2AVersionValidator.validateProtocolVersion(getAgentCardInternal(), context)andA2AExtensions.validateRequiredExtensions(getAgentCardInternal(), context)immediately aftercreateCallContext(...)in all nine previously-unvalidated methods, mirroring the existingsendMessage/sendStreamingMessagepattern. ForsubscribeToTaskthe checks are placed afterinstallForkedContextWrapper, matchingsendStreamingMessage.Fix (transport/grpc/src/test/java/org/a2aproject/sdk/transport/grpc/handler/GrpcHandlerTest.java):
testVersionNotSupportedErrorOnGetTask: a handler with an incompatible requested protocol version ("2.0" vs the card's "1.0") now failsgetTaskwith gRPCUNIMPLEMENTED(mapped fromVersionNotSupportedError). PreviouslygetTaskskipped validation and would have returned the task.Behavior change: gRPC requests with an incompatible
A2A-Versionheader or missing required extensions are now rejected on all methods instead of only the two streaming/unary message methods. Requests carrying no version header are unaffected (they default to "0.3" compatibility per spec, and validation passes when the card supports a compatible version).Testing
mvn -pl transport/grpc test— 41 tests run, 0 failures, 0 errors, 0 skipped (BUILD SUCCESS), including the new regression testtestVersionNotSupportedErrorOnGetTask.