Fix recursive gRPC collection generation - #3990
Merged
Merged
Conversation
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.
Fixes #2515.
goa gencould overflow the stack or keep expanding code for a gRPC result whose children contain the same result type, such asCategoryResultwithArrayOf("CategoryResult"). The same problem affects recursive maps. These designs now generate finite conversion functions, and the generated clients and servers can convert finite nested values in both directions.Three generator responsibilities are involved:
All nine changed golden files were reviewed. The changes replace inline object element conversions with private helper calls; complete-file goldens include the extracted bodies. Public constructor signatures, protobuf schemas, scalar conversions, presence checks, and validation rules remain unchanged. The union test now inspects helper bodies as well as the outer conversion, since the union switch can move into an element helper.
Validation:
GOTOOLCHAIN=go1.25.14 make all(lint, the complete test suite, and JSON-RPC integration tests). New generated-module tests compile every package, exercise the original recursive result through response encoding/decoding and protobuf serialization, round-trip recursive arrays, maps, nested collections, and mutually recursive types through all four client/server conversions, reject invalid grandchildren, and check optional zero values and defaults. A separate helper-registry test checks sharing through several nested wrappers in either direction.Regenerate with a Goa version containing this fix. No DSL changes, wire migration, coordinated deployment, or new runtime configuration are required; existing generated programs do not change until regenerated. Reverting generated source restores prior behavior for previously working designs. Reverting the generator prevents the affected recursive designs from generating again. No exported Go API changes are introduced.