Commit f447e4e
authored
fix(grpc): preserve null values in protobuf Struct (#578)
## 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 #5761 parent 7cd30de commit f447e4e
3 files changed
Lines changed: 41 additions & 12 deletions
File tree
- src/grpc
- pb/google/protobuf
- test/server/grpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments