fix(types): reject multiple content oneof arms in Part.fromJSON - #654
Open
Varun-S10 wants to merge 1 commit into
Open
fix(types): reject multiple content oneof arms in Part.fromJSON#654Varun-S10 wants to merge 1 commit into
Varun-S10 wants to merge 1 commit into
Conversation
🧪 Code CoverageNo coverage changes. Generated by coverage-comment.yml |
Contributor
|
Any changes to the |
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.
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.Fixes #643 🦕.
What was the bug?
In the A2A protobuf specification, a
Partmessage has acontentfield defined as aoneof(text,raw,url,data), meaning only one of these fields can be present at a time.Previously, if incoming JSON contained multiple
contentfields (for example{ text: "hello", url: "https://example.com/x" }):Part.fromJSONdid not throw an error."text"and silently dropped"url"with zero warning or notice.In contrast,
a2a-pythonand the proto3 JSON specification treat multipleoneoffields as malformed input and reject them with a parse error.How is it fixed?
src/types/pb/a2a.ts:Part.fromJSONto verify that at most onecontentoneof field is present.Message type "lf.a2a.v1.Part" should not have multiple "content" oneof fields: ...) when multiple arms are supplied.test/types/part_oneof.spec.ts:text,raw,url,data), empty content, and multiple arm combinations.Verification
Part.fromJSONthrows on multiple oneof fields.test/types/part_oneof.spec.tspassed (8/8).npm test) passed (69 test files, 1,495 tests).npm run lint) passed with 0 errors.npm run buildandnpm run test-build) passed.