fix(server): treat blank taskId/contextId as absent in message/send - #1172
Merged
Merged
Conversation
Proto3 scalar fields have no wire-level presence, so a message that never set taskId/contextId and one that explicitly serialized them as "" are indistinguishable once they cross a transport that always serializes non-optional fields. DefaultRequestHandler only checked for null, so a blank taskId was mistaken for a reference to an existing task with id "" instead of a request to start a new task, causing a spurious TaskNotFoundError (or a raw backend error, depending on the TaskStore implementation) for legitimate new-task requests. Normalize blank taskId/contextId to null once, at the top of onMessageSend/onMessageSendStream, mirroring the emptyToNull convention already used on the gRPC mapping path (A2ACommonFieldMapper). Also harden the public authorizeTaskAccess(String, ...) overload, which is called directly by transport handlers with a raw id. Message.Builder's taskId()/contextId() setters are annotated @nullable to match the record's own nullable fields, since normalization needs to pass null through them. This fixes a2aproject#1171 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MKiygCWwiHF1q8R5MgWx18
Collaborator
|
@paulrutter thanks! |
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.
Proto3 scalar fields have no wire-level presence, so a message that never set taskId/contextId and one that explicitly serialized them as "" are indistinguishable once they cross a transport that always serializes non-optional fields. DefaultRequestHandler only checked for null, so a blank taskId was mistaken for a reference to an existing task with id "" instead of a request to start a new task, causing a spurious TaskNotFoundError (or a raw backend error, depending on the TaskStore implementation) for legitimate new-task requests.
Normalize blank taskId/contextId to null once, at the top of onMessageSend/onMessageSendStream, mirroring the emptyToNull convention already used on the gRPC mapping path (A2ACommonFieldMapper). Also harden the public authorizeTaskAccess(String, ...) overload, which is called directly by transport handlers with a raw id. Message.Builder's taskId()/contextId() setters are annotated @nullable to match the record's own nullable fields, since normalization needs to pass null through them.
This fixes #1171
Description
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.