Skip to content

fix(gengateway): read oneof member response bodies through getters - #7740

Open
cvas22 wants to merge 1 commit into
grpc-ecosystem:mainfrom
cvas22:fix/response-body-oneof-member
Open

cvas22 wants to merge 1 commit into
grpc-ecosystem:mainfrom
cvas22:fix/response-body-oneof-member

Conversation

@cvas22

@cvas22 cvas22 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

References to other Issues or PRs

Fixes #7739, related to #1264

Have you read the Contributing Guidelines?

Yes

Brief description of what is fixed or changed

When response_body points at a oneof member, XXX_ResponseBody used AssignableExpr, which turns into response.Result.(*ExampleResponse_Text).Text. That panics as soon as the server sets the other member or leaves the oneof empty. Now paths that go through a oneof member are read with the generated getters (response.GetText()), which return the zero value instead, the same way the opaque template already does it. Paths without a oneof keep the current expression, so none of the generated examples change.

Other comments

I added a template test for a oneof member response body (it fails on main with the type assertion) and unit tests for the two new FieldPath helpers. This doesn't add support for naming the oneof itself in response_body, which is what #1264 asks for.

A response_body that names a oneof member was read with an unchecked
type assertion on the oneof, which panics when another member is set or
the oneof is empty. Use the generated getters for such paths.

Fixes grpc-ecosystem#7739

This branch has not been deployed

No deployments
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.

response_body on a oneof member panics when another member is set

1 participant