Skip to content

test: add proto3 JSON conformance spec for the generated codecs - #644

Open
ishan-1010 wants to merge 1 commit into
a2aproject:mainfrom
ishan-1010:test/proto-json-conformance
Open

test: add proto3 JSON conformance spec for the generated codecs#644
ishan-1010 wants to merge 1 commit into
a2aproject:mainfrom
ishan-1010:test/proto-json-conformance

Conversation

@ishan-1010

@ishan-1010 ishan-1010 commented Aug 10, 2026

Copy link
Copy Markdown

Description

What

Adds test/proto_json_conformance.spec.ts, covering how the generated codecs handle
proto3 JSON. Ten cases: five that pass today and pin behaviour that's already correct,
and five marked it.fails for the divergences in #640, #641, #642 and #643.

No source changes. This documents current behaviour and gives the fixes a regression net
to land against.

Why

These messages go over the wire to SDKs generated from the same .proto with a different
toolchain, so the JSON has to agree. I built a differential harness that round-trips a
shared corpus through this SDK and a2a-python and diffs the output, and it turned up
four disagreements:

  • unknown enum values become "UNRECOGNIZED", which a2a-python rejects
  • Timestamp is an unvalidated string and is never normalized to UTC
  • Part.data set to null drops the content oneof
  • multiple content oneof arms are accepted instead of rejected

Each is filed separately with a full repro. This PR is just the tests.

On it.fails

it.fails asserts that the body fails, so the suite is green today and goes red the
moment a bug is fixed. That's deliberate: the fix can't land without flipping the marker,
so none of these can be quietly resolved and forgotten. I checked the inversion is strict
with a control test whose body passes, and vitest reports it as a failure.

The five passing cases are there as controls. If a change breaks known-good behaviour like
bytes or non-ASCII round-tripping, those go red on their own.

Where the fixes should go

All four live in src/types/pb/a2a.ts, which is generated and marked DO NOT EDIT, and I
couldn't find a regeneration path in the repo. Two of them, the enum sentinel and the
oneof leniency, are ts-proto behaviour rather than anything configurable, so I didn't
want to guess. Happy to send the fixes once you've said whether you'd prefer them patched
into the generated output, handled in a normalization layer at the transport boundary, or
raised upstream.

Verification

npx vitest run                                        69 files, 1497 tests, all pass
npx vitest run test/proto_json_conformance.spec.ts    10 tests, all pass
npx tsc --noEmit -p tsconfig.test.json                clean
npx eslint test/proto_json_conformance.spec.ts        clean

Reproduced against @a2a-js/sdk 1.0.1 from npm as well as main at 1c6eb32, so none of
this is a main-only artifact. Python side pinned at a2a-python cff6727.

Parts of this were put together with AI assistance. Every case was verified by hand
against both SDKs before filing.

Refs #640, #641, #642, #643

Round-tripping a shared corpus through this SDK and a2a-python turned up four
places where the generated codecs disagree with proto3 JSON. Covers all four as
it.fails, plus five passing cases pinning behaviour that is already correct.

No source changes.

Refs a2aproject#640, a2aproject#641, a2aproject#642, a2aproject#643
@ishan-1010
ishan-1010 requested a review from a team as a code owner August 10, 2026 18:57
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

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.

1 participant