Repository navigation
Fix nested body path initialization for oneof fields - #6948
Conversation
johanbrandhorst
left a comment
There was a problem hiding this comment.
Thanks for this PR! Could you make a change to one of our example protobuf files that would reproduce this bug, so we can protect against it breaking again in the future? See examples/internal/proto.
|
Updated to address the review request by adding a protobuf fixture that reproduces the nested body path through an intermediate message to a oneof field. I also excluded Verification:
|
johanbrandhorst
left a comment
There was a problem hiding this comment.
This... is not what I asked for? I asked for you to ideally update one of the existing protobuf example files, but you've added a new protobuf file as testdata, and then promptly excluded it from the generation path? Please remove the changes to buf.gen.yaml and the new protobuf file, it would be much better if you just edited a_bit_of_everthing.proto or one of the others.
|
@cyphercodes Hi! Any updates? |
|
Thanks for the ping. I checked the existing-example route requested in the last review: adding a nested body path such as The current Bazel failure is the expected generated I don't want to broaden this PR into OpenAPI nested-body support without maintainer direction. Which direction would you prefer?
|
|
I'm confused by your answer. This fixes an issue in the gateway generator, right? If so, we should definitely just go ahead and fix that same issue in the openapiv2 generator and include an example in |
|
@cyphercodes Hi! Any updates? |
|
Updated this to match the requested existing-example direction. Changes:
Verification:
|
|
@johanbrandhorst Hi! Could you review the changes? |
|
@johanbrandhorst ping) |
|
Updated to address the latest review and generated-artifact failure. I restored the explanatory Verification:
|
|
Looks like there's still a bazel error |
|
Updated the Bazel BUILD files that Verification:
|
References to other Issues or PRs
Fixes #6938
Have you read the Contributing Guidelines?
Yes.
Brief description of what is fixed or changed
AssignableExprPrepnow initializes singular intermediate message fields before descending into nested body/path field expressions. This prevents generated gateway handlers from dereferencing a nil parent message when a body selector traverses through a message field to a oneof field.A regression test covers the
input.input_valueshape from the issue and verifies the parent message initialization is emitted before the oneof wrapper initialization.Other comments
Tests run:
go test ./internal/descriptor ./protoc-gen-grpc-gateway/...