Skip to content

fix(grpc): preserve null values in protobuf Struct#578

Merged
JakubWorek merged 1 commit into
a2aproject:epic/1.0_breaking_changesfrom
MyPrototypeWhat:agent/fix-grpc-null-serialization
Jul 16, 2026
Merged

fix(grpc): preserve null values in protobuf Struct#578
JakubWorek merged 1 commit into
a2aproject:epic/1.0_breaking_changesfrom
MyPrototypeWhat:agent/fix-grpc-null-serialization

Conversation

@MyPrototypeWhat

@MyPrototypeWhat MyPrototypeWhat commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • update the ts-proto generator from v2.6.1 to v2.11.0 so generated google.protobuf.Struct wrappers preserve JavaScript null
  • encode JavaScript null as google.protobuf.NullValue.NULL_VALUE
  • decode the protobuf nullValue case back to JavaScript null
  • add a wire-level regression test covering direct, nested, and array metadata values

Root cause

The generated Value.wrap() implementation assigned the literal JavaScript null to a protobuf enum field. @bufbuild/protobuf requires an integer enum value, so gRPC serialization failed with invalid int32: object.

The reverse conversion also returned the enum value 0 instead of restoring JSON null. The newer ts-proto output corrects both directions so google.protobuf.Struct fields preserve JSON semantics across the gRPC wire.

Impact

Tasks, messages, and other A2A gRPC payloads can now contain valid JSON null values in metadata or other Struct-backed fields without crashing or changing them to 0 after deserialization.

Target branch

This PR is rebased onto and directly targets epic/1.0_breaking_changes for the stable 1.0.0 SDK work.

Generation note

The checked-in 1.0 bindings contain post-generation adjustments. A full buf generate currently rewrites those bindings and adds unrelated generated files, so this PR refreshes only the affected Struct artifact together with the generator pin to keep the fix scoped.

Validation

  • npm test — 66 files, 1,375 tests passed
  • npm run test:edge — 49 files, 1,081 tests passed, 2 skipped
  • npm run build — passed
  • npm run test-build — passed
  • npm run lint:ci — passed in GitHub Actions

Fixes #576

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes an issue with protobuf serialization where null values were not correctly preserved. It updates the wrap and unwrap functions in struct.ts and adds a test suite to verify the behavior. Feedback was provided noting that modifying generated files directly is a maintenance risk, and alternative approaches like post-generation scripts or patching were suggested.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/grpc/pb/google/protobuf/struct.ts
@MyPrototypeWhat
MyPrototypeWhat marked this pull request as ready for review July 16, 2026 10:24
@MyPrototypeWhat
MyPrototypeWhat requested a review from a team as a code owner July 16, 2026 10:24
@JakubWorek

Copy link
Copy Markdown
Collaborator

Hi @MyPrototypeWhat, thank you for the fix. As you mentioned in the PR description we are working towards releasing stable 1.0.0 version of a2a-js sdk. Can you please rebase your current branch to epic/1.0 and fix it there directly also updating the base branch of this PR?

@MyPrototypeWhat
MyPrototypeWhat force-pushed the agent/fix-grpc-null-serialization branch from 4d4ff77 to fd5501b Compare July 16, 2026 11:06
@MyPrototypeWhat
MyPrototypeWhat changed the base branch from main to epic/1.0_breaking_changes July 16, 2026 11:07
@MyPrototypeWhat

Copy link
Copy Markdown
Author

Done — I rebased the PR onto the current epic/1.0_breaking_changes branch and updated the PR base accordingly. I also updated the ts-proto generator pin and adapted the regression test to the 1.0 generated service layout. Validation on the rebased branch: 1,375 main tests passed; 1,081 edge tests passed (2 skipped); build and test-build passed.

@MyPrototypeWhat
MyPrototypeWhat force-pushed the agent/fix-grpc-null-serialization branch from fd5501b to 46d37af Compare July 16, 2026 11:11
@JakubWorek
JakubWorek merged commit f447e4e into a2aproject:epic/1.0_breaking_changes Jul 16, 2026
14 checks passed
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.

gRPC: Task/Message metadata field with a null value crashes serialization ("invalid int32: object")

2 participants