Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drain req.body on server stream methods with no body defined #5240

Merged
merged 7 commits into from
Feb 22, 2025

Conversation

paskozdilar
Copy link
Contributor

This will prevent connection leaking when client sends a body on a method with no body defined. It will cause hanging when client sends a body stream, but such calls will hang anyway, even without the fix.

Fixes #5236.

References to other Issues or PRs

#5236

Have you read the Contributing Guidelines?

Yes.

Brief description of what is fixed or changed

When an HTTP client send body on a method which doesn't have (google.api.http) { body } annotation defined, grpc-gateway never closes context, causing connection leaks.
This PR drains req.Body on every method which doesn't have body annotation defined, so methods will work even if client sends body.

Other comments

@paskozdilar paskozdilar changed the title Read body on server stream methods with no body defined Drain req.body on server stream methods with no body defined Feb 14, 2025
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Any chance you could add an integration test that was broken before this? See https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/integration/integration_test.go for the existing integration tests. You may need to add some more definitions to the test protos.

@johanbrandhorst
Copy link
Collaborator

I take it you're working on those tests I requested, but also just letting you know that you'll need to regenerate the proto files. See CONTRIBUTING.md for steps.

@paskozdilar
Copy link
Contributor Author

Since this PR solves a server problem, not a client one, integration tests need to track whether server context is closed when the request fails. That doesn't fit well in the current stucture of the tests.

I'm trying to think of an elegant solution that doesn't involve forwarding a value through RunMain and server.Run.
Perhaps starting an ad-hoc server in the test method would be the pragmatic thing here?

@paskozdilar
Copy link
Contributor Author

paskozdilar commented Feb 16, 2025

Yeah, seems like logRequestBody middleware itself performs io.ReadAll on the body, and therefore hides this issue.
Running an ad-hoc gateway is the only sensible way to do this.

@paskozdilar
Copy link
Contributor Author

paskozdilar commented Feb 16, 2025

Alright, I added a special case in gateway setup for "/rpc/no-body/" methods just to remove the logger middleware, and now it seems to work fine.

Test on main:

=== RUN   TestNoBodyPost
    integration_test.go:2748: server context not done
    integration_test.go:2777: server context not done
--- FAIL: TestNoBodyPost (2.00s)
FAIL
FAIL    github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/integration 12.017s
FAIL

Test on my branch:

=== RUN   TestNoBodyPost
--- PASS: TestNoBodyPost (0.00s)
PASS
ok      github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/integration 10.014s

You can find the failing test on branch main-failing-test in my repository.

Please let me know if this is acceptable, or if there's anything you'd prefer to be done differently.

@paskozdilar paskozdilar force-pushed the main branch 2 times, most recently from 27cb4b6 to f3ca564 Compare February 16, 2025 17:48
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, just resolve the protobuf lint warnings please!

@paskozdilar
Copy link
Contributor Author

Done, should have no lint warnings anymore.

@johanbrandhorst
Copy link
Collaborator

🤔 looks like Bazel failed to compile, that's a bit odd since the non-bazel build and generate job succeeded.

@paskozdilar
Copy link
Contributor Author

Unfortunately, I'm not experienced with Bazel at all.

These logs make me thing it's some kind of caching issue:

examples/internal/proto/examplepb/no_body_post.pb.gw.go:39:6: request_NoBodyPostService_RpcEmptyRpc_0 redeclared in this block
	bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:39:6: other declaration of request_NoBodyPostService_RpcEmptyRpc_0

I'll try to get into Bazel to maybe figure out stuff, but considering 1) my lack of experience with Bazel 2) my complete ignorance of the build environment, I wouldn't hope for much.

@paskozdilar
Copy link
Contributor Author

Nope, it seems that Bazel failes on that exact line:

diff --git a/examples/internal/proto/examplepb/BUILD.bazel b/examples/internal/proto/examplepb/BUILD.bazel
index e27d6dd..5db1a4d 100644
--- a/examples/internal/proto/examplepb/BUILD.bazel
+++ b/examples/internal/proto/examplepb/BUILD.bazel
@@ -127,7 +127,6 @@ go_proto_library(
 go_library(
     name = "examplepb",
     srcs = [
-        "no_body_post.pb.go",
         "no_body_post.pb.gw.go",
         "openapi_merge_a.pb.go",
         "openapi_merge_a.pb.gw.go",
Error: Process completed with exit code 1.

Reverting the commit.

@paskozdilar
Copy link
Contributor Author

I've invited you as a collaborator so you can push directly on my fork if you wish so.

@paskozdilar
Copy link
Contributor Author

paskozdilar commented Feb 20, 2025

I've found a way to reproduce the CI fail locally:

#!/usr/bin/env bash

cd $(dirname $0)

docker run -v $(pwd):/grpc-gateway -v $(pwd)/certs:/etc/ssl/certs -w /grpc-gateway --rm ghcr.io/grpc-ecosystem/grpc-gateway/build-env:1.23 \
    /bin/bash -c 'make install && \
        make clean && \
        make generate'
docker run -itv $(pwd):/grpc-gateway -v $(pwd)/certs:/etc/ssl/certs -w /grpc-gateway --entrypoint /bin/bash --rm \
    ghcr.io/grpc-ecosystem/grpc-gateway/build-env:1.23 -c '\
        bazel run :gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories && \
        bazel run :gazelle && \
        bazel run :buildifier &&
        bazel test //...'

It prints the same error.

@paskozdilar
Copy link
Contributor Author

Here's the full error, printed when --sandbox_debug flag is passed go bazel test //...:

ERROR: /grpc-gateway/examples/internal/proto/examplepb/BUILD.bazel:127:11: GoCompilePkg examples/internal/proto/examplepb/examplepb.a failed: (Exit 1): process-wrapper failed: error executing GoCompilePkg command
  (cd /home/vscode/.cache/bazel/_bazel_vscode/040e700c618bb93b01649f0eaa236eab/sandbox/processwrapper-sandbox/928/execroot/_main && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=amd64 \
    GODEBUG='winsymlink=0' \
    GOEXPERIMENT=nocoverageredesign \
    GOOS=linux \
    GOPATH='' \
    GOROOT_FINAL=GOROOT \
    GOTOOLCHAIN=local \
    PATH=/usr/bin:/bin \
    TMPDIR=/tmp \
    ZERO_AR_DATE=1 \
  /home/vscode/.cache/bazel/_bazel_vscode/install/0b6397354bedad4359bdae4332ce8fc5/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/home/vscode/.cache/bazel/_bazel_vscode/040e700c618bb93b01649f0eaa236eab/sandbox/processwrapper-sandbox/928/stats.out' bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+grpc_ecosystem_grpc_gateway__download_0/builder_reset/builder compilepkg -sdk external/rules_go++go_sdk+grpc_ecosystem_grpc_gateway__download_0 -goroot bazel-out/k8-fastbuild/bin/external/rules_go+/stdlib_ -installsuffix linux_amd64 -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/a_bit_of_everything.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/echo_service.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/enum_with_single_value.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/flow_combination.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generate_unbound_methods.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generated_output.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/ignore_comment.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/non_standard_names.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/remove_internal_comment.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/response_body_service.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/stream.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/unannotated_echo_service.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/use_go_template.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/visibility_rule_echo_service.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/wrappers.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/a_bit_of_everything_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/echo_service_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/enum_with_single_value_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/flow_combination_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generate_unbound_methods_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generated_output_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/ignore_comment_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/non_standard_names_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/remove_internal_comment_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/response_body_service_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/stream_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/unannotated_echo_service_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/use_go_template_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/visibility_rule_echo_service_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/wrappers_grpc.pb.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/a_bit_of_everything.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/echo_service.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/enum_with_single_value.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/flow_combination.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generate_unbound_methods.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/generated_output.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/ignore_comment.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/non_standard_names.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/remove_internal_comment.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/response_body_service.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/stream.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/unannotated_echo_service.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/use_go_template.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/visibility_rule_echo_service.pb.gw.go -src bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/wrappers.pb.gw.go -src examples/internal/proto/examplepb/no_body_post.pb.gw.go -src examples/internal/proto/examplepb/openapi_merge_a.pb.go -src examples/internal/proto/examplepb/openapi_merge_a.pb.gw.go -src examples/internal/proto/examplepb/openapi_merge_a_grpc.pb.go -src examples/internal/proto/examplepb/openapi_merge_b.pb.go -src examples/internal/proto/examplepb/openapi_merge_b.pb.gw.go -src examples/internal/proto/examplepb/openapi_merge_b_grpc.pb.go -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/runtime=github.com/grpc-ecosystem/grpc-gateway/v2/runtime=bazel-out/k8-fastbuild/bin/runtime/runtime.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/utilities=github.com/grpc-ecosystem/grpc-gateway/v2/utilities=bazel-out/k8-fastbuild/bin/utilities/utilities.x' -arc 'google.golang.org/genproto/googleapis/api/annotations=google.golang.org/genproto/googleapis/api/annotations=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_genproto_googleapis_api/annotations/annotations.x' -arc 'google.golang.org/grpc=google.golang.org/grpc=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_grpc/grpc.x' -arc 'google.golang.org/grpc/codes=google.golang.org/grpc/codes=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_grpc/codes/codes.x' -arc 'google.golang.org/grpc/grpclog=google.golang.org/grpc/grpclog=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_grpc/grpclog/grpclog.x' -arc 'google.golang.org/grpc/metadata=google.golang.org/grpc/metadata=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_grpc/metadata/metadata.x' -arc 'google.golang.org/grpc/status=google.golang.org/grpc/status=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_grpc/status/status.x' -arc 'google.golang.org/protobuf/proto=google.golang.org/protobuf/proto=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/proto/proto.x' -arc 'google.golang.org/protobuf/reflect/protoreflect=google.golang.org/protobuf/reflect/protoreflect=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/reflect/protoreflect/protoreflect.x' -arc 'google.golang.org/protobuf/runtime/protoimpl=google.golang.org/protobuf/runtime/protoimpl=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/runtime/protoimpl/protoimpl.x' -arc 'google.golang.org/protobuf/types/known/emptypb=google.golang.org/protobuf/types/known/emptypb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/emptypb/emptypb.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum=github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum=bazel-out/k8-fastbuild/bin/examples/internal/proto/oneofenum/oneofenum.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum=github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum=bazel-out/k8-fastbuild/bin/examples/internal/proto/pathenum/pathenum.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub=github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub=bazel-out/k8-fastbuild/bin/examples/internal/proto/sub/sub.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2=github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2=bazel-out/k8-fastbuild/bin/examples/internal/proto/sub2/sub2.x' -arc 'github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options=github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options=bazel-out/k8-fastbuild/bin/protoc-gen-openapiv2/options/options.x' -arc 'github.com/golang/protobuf/descriptor=github.com/golang/protobuf/descriptor=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+com_github_golang_protobuf/descriptor/descriptor.x' -arc 'google.golang.org/genproto/googleapis/api/httpbody=google.golang.org/genproto/googleapis/api/httpbody=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_genproto_googleapis_api/httpbody/httpbody.x' -arc 'google.golang.org/genproto/googleapis/api/visibility=google.golang.org/genproto/googleapis/api/visibility=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_genproto_googleapis_api/visibility/visibility.x' -arc 'google.golang.org/genproto/googleapis/rpc/status=google.golang.org/genproto/googleapis/rpc/status=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_genproto_googleapis_rpc/status/status.x' -arc 'github.com/golang/protobuf/proto=github.com/golang/protobuf/proto=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+com_github_golang_protobuf/proto/proto.x' -arc 'google.golang.org/protobuf/reflect/protoregistry=google.golang.org/protobuf/reflect/protoregistry=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/reflect/protoregistry/protoregistry.x' -arc 'google.golang.org/protobuf/runtime/protoiface=google.golang.org/protobuf/runtime/protoiface=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/runtime/protoiface/protoiface.x' -arc 'google.golang.org/protobuf/types/descriptorpb=google.golang.org/protobuf/types/descriptorpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/descriptorpb/descriptorpb.x' -arc 'google.golang.org/protobuf/types/known/anypb=google.golang.org/protobuf/types/known/anypb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/anypb/anypb.x' -arc 'google.golang.org/protobuf/types/known/apipb=google.golang.org/protobuf/types/known/apipb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/apipb/apipb.x' -arc 'google.golang.org/protobuf/types/known/durationpb=google.golang.org/protobuf/types/known/durationpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/durationpb/durationpb.x' -arc 'google.golang.org/protobuf/types/known/fieldmaskpb=google.golang.org/protobuf/types/known/fieldmaskpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/fieldmaskpb/fieldmaskpb.x' -arc 'google.golang.org/protobuf/types/known/sourcecontextpb=google.golang.org/protobuf/types/known/sourcecontextpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/sourcecontextpb/sourcecontextpb.x' -arc 'google.golang.org/protobuf/types/known/structpb=google.golang.org/protobuf/types/known/structpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/structpb/structpb.x' -arc 'google.golang.org/protobuf/types/known/timestamppb=google.golang.org/protobuf/types/known/timestamppb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/timestamppb/timestamppb.x' -arc 'google.golang.org/protobuf/types/known/typepb=google.golang.org/protobuf/types/known/typepb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/typepb/typepb.x' -arc 'google.golang.org/protobuf/types/known/wrapperspb=google.golang.org/protobuf/types/known/wrapperspb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/known/wrapperspb/wrapperspb.x' -arc 'google.golang.org/protobuf/types/pluginpb=google.golang.org/protobuf/types/pluginpb=bazel-out/k8-fastbuild/bin/external/gazelle++go_deps+org_golang_google_protobuf/types/pluginpb/pluginpb.x' -importpath github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb -p github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb -package_list bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go++go_sdk+grpc_ecosystem_grpc_gateway__download_0/packages.txt -embedroot bazel-out/k8-fastbuild/bin -embedroot '' -embedlookupdir examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb -embedlookupdir examples/internal/proto/examplepb -lo bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb.a -o bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb.x -gcflags '')
examples/internal/proto/examplepb/no_body_post.pb.gw.go:39:6: request_NoBodyPostService_RpcEmptyRpc_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:39:6: other declaration of request_NoBodyPostService_RpcEmptyRpc_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:49:6: local_request_NoBodyPostService_RpcEmptyRpc_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:49:6: other declaration of local_request_NoBodyPostService_RpcEmptyRpc_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:58:6: request_NoBodyPostService_RpcEmptyStream_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:58:6: other declaration of request_NoBodyPostService_RpcEmptyStream_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:81:6: RegisterNoBodyPostServiceHandlerServer redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:81:6: other declaration of RegisterNoBodyPostServiceHandlerServer
examples/internal/proto/examplepb/no_body_post.pb.gw.go:115:6: RegisterNoBodyPostServiceHandlerFromEndpoint redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:115:6: other declaration of RegisterNoBodyPostServiceHandlerFromEndpoint
examples/internal/proto/examplepb/no_body_post.pb.gw.go:139:6: RegisterNoBodyPostServiceHandler redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:139:6: other declaration of RegisterNoBodyPostServiceHandler
examples/internal/proto/examplepb/no_body_post.pb.gw.go:148:6: RegisterNoBodyPostServiceHandlerClient redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:148:6: other declaration of RegisterNoBodyPostServiceHandlerClient
examples/internal/proto/examplepb/no_body_post.pb.gw.go:187:2: pattern_NoBodyPostService_RpcEmptyRpc_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:187:2: other declaration of pattern_NoBodyPostService_RpcEmptyRpc_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:188:2: pattern_NoBodyPostService_RpcEmptyStream_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:188:2: other declaration of pattern_NoBodyPostService_RpcEmptyStream_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:192:2: forward_NoBodyPostService_RpcEmptyRpc_0 redeclared in this block
        bazel-out/k8-fastbuild/bin/examples/internal/proto/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb/no_body_post.pb.gw.go:192:2: other declaration of forward_NoBodyPostService_RpcEmptyRpc_0
examples/internal/proto/examplepb/no_body_post.pb.gw.go:192:2: too many errors
compilepkg: error running subcommand external/rules_go++go_sdk+grpc_ecosystem_grpc_gateway__download_0/pkg/tool/linux_amd64/compile: exit status 2
INFO: Elapsed time: 9.374s, Critical Path: 5.90s
INFO: 539 processes: 97 internal, 442 processwrapper-sandbox.
ERROR: Build did NOT complete successfully
//protoc-gen-openapiv2/internal/genopenapi:genopenapi_test            NO STATUS
//runtime:runtime_test                                                NO STATUS
//examples/internal/integration:integration_test                FAILED TO BUILD
//internal/casing:casing_test                                            PASSED in 0.1s
//internal/codegenerator:codegenerator_test                              PASSED in 0.0s
//internal/descriptor:descriptor_test                                    PASSED in 0.0s
//internal/httprule:httprule_test                                        PASSED in 0.0s
//protoc-gen-grpc-gateway/internal/gengateway:gengateway_test            PASSED in 0.0s
//protoc-gen-openapiv2:protoc-gen-openapiv2_test                         PASSED in 0.0s
//utilities:utilities_test                                               PASSED in 0.1s

Comment on lines +21 to +22
# gazelle:exclude no_body_post.pb.gw.go
# gazelle:exclude no_body_post_grpc.pb.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was what was missing, it passes locally for me now

paskozdilar and others added 7 commits February 21, 2025 20:07
This will prevent connection leaking when client sends a body on a
method with no body defined. It will cause hanging when client sends a
body stream, but such calls will hang anyway, even without the fix.

Fixes grpc-ecosystem#5236.
Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]>
@johanbrandhorst
Copy link
Collaborator

Just did a rebase to fix a conflict

@johanbrandhorst johanbrandhorst merged commit 18ed247 into grpc-ecosystem:main Feb 22, 2025
14 checks passed
@johanbrandhorst
Copy link
Collaborator

Thanks for your contribution and for your patience with the CI checks :)!

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.

ServerStream client context never closes when using google.protobuf.Empty without body annotation
2 participants