Repository navigation
Reuse the stream item wrapper message in gRPC stream envelopes - #4072
Merged
raphael merged 2 commits intoOct 28, 2026
Merged
Conversation
A gRPC method with both Payload and a primitive or collection StreamingPayload declared its stream item wrapper twice: once as the top-level stream item message and again, suffixed with 2, as the envelope's stream_item branch. The generated client and server then mixed the two types and did not compile. The catalog now keeps the root identity of a wrapper that is reached again through the stream envelope, so both uses share one message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thanks for tracking this down and fixing it! I pushed a small follow-up commit with two refinements:
|
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.
Since v3.31.0, a gRPC method that defines both
Payload(...)and a primitive or collectionStreamingPayload(...)generates client and server code that does not compile. v3.30.0 generates working code for the same design. I couldn't find an existing issue, so here is the reproduction:The
.protodeclares the stream item wrapper twice. The envelope'sstream_itembranch usesUploadStreamItem2, while validation and conversion useUploadStreamItem:The protobuf catalog collects the stream item wrapper as a root message, with the endpoint's streaming request identity. It then reaches the same wrapper again through the envelope's
stream_itembranch. IncollectMessageRecursive, a non-root generated wrapper always receives a new synthetic wrapper identity, even when its origin is already bound to a root source. The two identities differ, so the catalog declares a second message and suffixes it. This isn't the intended suffixing of a real protobuf name collision: both declarations describe the same wrapper. Object stream items are not affected because they are not generated wrappers.The catalog now keeps the root identity when a generated wrapper's origin is already a root message, so the envelope branch and the stream item share one message, as in v3.30.0. Other generated wrappers still receive their own declarations.
The new table-driven generator test covers client streams with
Bytes,IntandArrayOf(String)items and a bidirectional stream withBytesitems. It asserts that the.protodeclares one stream item message, referenced bystream_item, and compiles the generated packages. Every case fails without the fix. The existingClientStreamingRPCWithPayloadDSLandBidirectionalStreamingRPCWithPayloadDSLgoldens cover only handler and endpoint init sections, which is why this wasn't caught.make testand golangci-lint v2.14.0 (run ./...) pass with Go 1.27.3. Thetest-pluginsandtest-examplestargets mentioned in CONTRIBUTING.md are no longer in the Makefile, so they were not run.🤖 Generated with Claude Code