Search code examples
protocol-buffersgrpcenvoyproxy

Envoy gRPC-JSON Transcoder with special characters in query param names


We would like to use protocol buffers to define our API, and then use envoy and the gRPC-JSON transcoder filter to provide an HTTP/JSON endpoint.

We are trying to migrate an existing API over, and this API uses query string parameters like ?search[field]=value where field is the name of the field you want to search on, and value is the value of the field you are filtering on.

So we have a protobuf similar to this (I cut out the unimportant stuff):

message ListRequest {
  string search_field1 = 1 [json_name = "search[field1]"];
  string search_field2 = 2 [json_name = "search[field2]"];
  string search_field3 = 3 [json_name = "search[field3]"];
}

message ListCallbacksResponse {
}

service Service {
  rpc List(ListRequest) returns (ListResponse) {
    option (google.api.http) = {
      get: "/v1/list"
    };
  }
}

However, when we make the request (either with [...] or %5B...%5D) it doesn't work. For instance:

http://localhost/v1/list?search%5Bfield1%5D=field1value

or

http://localhost/v1/list?search[field1]=field1value

However, if we update the protobuf to look like this:

message ListRequest {
  string search_field1 = 1 [json_name = "search%5Bfield1%5D"];
  string search_field2 = 2 [json_name = "search%5Bfield2%5D"];
  string search_field3 = 3 [json_name = "search%5Bfield3%5D"];
}

Then it seems to work. But this doesn't seem right to me. Is there a setting or something I am missing?

I've also opened an issue on envoy's github.


Solution

  • Seems as though this was an issue in the grpc-httpjson-transcoding which has been fixed and now part of envoy as of v1.23.0