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

[gRPC-gateway] Empty arrays are decoded as {} (which should be []) #10801

Closed
1 task done
StarlightIbuki opened this issue May 8, 2023 · 0 comments · Fixed by #10790
Closed
1 task done

[gRPC-gateway] Empty arrays are decoded as {} (which should be []) #10801

StarlightIbuki opened this issue May 8, 2023 · 0 comments · Fixed by #10790

Comments

@StarlightIbuki
Copy link
Contributor

StarlightIbuki commented May 8, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

*

Current Behavior

When a gRPC service returns an empty array, it's encoded as {} in the JSON body.

Expected Behavior

It should be encoded as [].

Steps To Reproduce

//... some service
  rpc Echo(EchoMsg) returns (EchoMsg) {
    option (google.api.http) = {
      post: "/v1/echo"
      body: "*"
    };
  }

//...
message EchoMsg {
  repeated string array = 1;
  string nullable = 2;
}
func (s *server) Echo(ctx context.Context, in *pb.EchoMsg) (*pb.EchoMsg, error) {
	return in, nil
}
local req_body = { array = {}, nullable = "ahaha" }
local res, _ = proxy_client:post("/v1/echo", {
   headers = { ["Content-Type"] = "application/json" },
    body = req_body,
})

res:read_body() would return something like { "array": {}, "nullable": "ahaha"}.

Anything else?

This issue is created for visibility for an internal ticket(FTI-5002).

windmgc pushed a commit that referenced this issue May 15, 2023
We found an issue when testing the fix of #10801. When a service responds with a message with all default value fields, the JSON response would be totally empty.

The reason for this issue is that we assume a message to be at least of length 1 when unframing.

Removing this restriction (a message can be of length 0) fixes this issue.

Fix FTI-5054
Fix #10802
lhanjian pushed a commit that referenced this issue Dec 23, 2024
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 a pull request may close this issue.

1 participant