Skip to content

fix(types): reject multiple content oneof arms in Part.fromJSON - #654

Open
Varun-S10 wants to merge 1 commit into
a2aproject:mainfrom
Varun-S10:fix/issue-643
Open

fix(types): reject multiple content oneof arms in Part.fromJSON#654
Varun-S10 wants to merge 1 commit into
a2aproject:mainfrom
Varun-S10:fix/issue-643

Conversation

@Varun-S10

Copy link
Copy Markdown
Contributor

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:

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass
  • Appropriate docs were updated (if necessary)

Fixes #643 🦕.


What was the bug?

In the A2A protobuf specification, a Part message has a content field defined as a oneof (text, raw, url, data), meaning only one of these fields can be present at a time.

Previously, if incoming JSON contained multiple content fields (for example { text: "hello", url: "https://example.com/x" }):

  • Part.fromJSON did not throw an error.
  • It selected "text" and silently dropped "url" with zero warning or notice.

In contrast, a2a-python and the proto3 JSON specification treat multiple oneof fields as malformed input and reject them with a parse error.


How is it fixed?

  1. src/types/pb/a2a.ts:
    • Added validation inside Part.fromJSON to verify that at most one content oneof field is present.
    • Throws an error (Message type "lf.a2a.v1.Part" should not have multiple "content" oneof fields: ...) when multiple arms are supplied.
  2. test/types/part_oneof.spec.ts:
    • Added unit tests covering all single valid arms (text, raw, url, data), empty content, and multiple arm combinations.

Verification

  • Part.fromJSON throws on multiple oneof fields.
  • Unit tests in test/types/part_oneof.spec.ts passed (8/8).
  • Full test suite (npm test) passed (69 test files, 1,495 tests).
  • ESLint and TypeScript checks (npm run lint) passed with 0 errors.
  • Build checks (npm run build and npm run test-build) passed.

@Varun-S10
Varun-S10 requested a review from a team as a code owner August 14, 2026 05:45
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@bartek-gralewicz

Copy link
Copy Markdown
Contributor

Any changes to the src/types/a2a.ts are not permitted. This file is autogenerated based on the proto recipe. Please see the first line of the file: src/types/a2a.ts:1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: multiple content oneof arms are silently accepted instead of rejected

2 participants