Skip to content

Commit 3db6172

Browse files
committed
fix(grpc): Fix error "proto3 disallow 'optional' label"
When grpc-gateway plugin loads a proto3 proto file with optional labeled fields, it will throw an error "proto3 disallow 'optional' label". This fixes the issue by enabling proto3_optional in protoc.
1 parent 826214b commit 3db6172

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
message: Fixed an issue where gRPC plugins lack support for "optional".
2+
scope: Plugins
3+
type: bugfix

kong/tools/grpc.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function _M.new()
7777
protoc_instance:addpath(v)
7878
end
7979
protoc_instance.include_imports = true
80+
protoc_instance.proto3_optional = true
8081

8182
return setmetatable({
8283
protoc_instance = protoc_instance,

spec/fixtures/grpc/targetservice.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ service Bouncer {
5656

5757
message HelloRequest {
5858
string greeting = 1;
59-
bool boolean_test = 2;
59+
optional bool boolean_test = 2;
6060
}
6161

6262
message HelloResponse {

0 commit comments

Comments
 (0)