Description
Is there an existing issue for this?
- I have searched the existing issues
Kong version (3.9.0
)
3.9.0
Current Behavior
I have grpc-gateway
plugin enabled for a grpc backend service with http mappings defined in the proto file.
The error proto3 disallow 'optional' label
is shown in kong logs when making an Http request to a rpc method with optional labeled field in the request.
kong-1 | 2025/04/11 17:49:53 [error] 1411#0: *6441 [kong] init.lua:406 [grpc-gateway] /usr/local/share/lua/5.1/protoc.lua:651: /protos/proto/feature-a/v1/feature-a-health.proto:23:12: proto3 disallow 'optional' label, client: 192.168.65.1
I experimented and found that adding this line to function _M.new()
in kong/tools/grpc.lua fixes the error
protoc_instance.proto3_optional = true
Expected Behavior
grpc-gateway should successfully load the proto file and route the http request to the rpc method
Steps To Reproduce
kong.yaml
- name: feature-a-user
protocol: grpc
host: grpc-example
port: 50051
routes:
- name: feature-a-user
protocols:
- http
paths:
- /v1/feature-a/user/
strip_path: true
plugins:
- name: grpc-gateway
config:
proto: feature-a/v1/feature-a-user.proto
feature-a-user.proto
syntax = "proto3";
package feature.user.v1;
import "google/api/annotations.proto";
service User {
rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse) {
option (google.api.http) = {
patch: "/v1/feature-a/user/{id}"
body: "*"
};
}
}
message UpdateUserRequest {
string id = 1;
optional string name = 2;
optional string email = 3;
}
Http request
curl -X PATCH 0.0.0.0:8000/v1/feature-a/user/1 -d '{"name": "test"}'
Anything else?
I tried to push a branch to this repo with the change to grpc.lua, however I am getting permission denied. I can make the PR if I'm granted permissions to push branches and create PRs
Metadata
Metadata
Assignees
Labels
No labels