grpc-node
grpc-node copied to clipboard
Support proto3 optional with grpc_tools_node_protoc_plugin
Problem description
I'm using rules_proto_grpc to generate node targets which are consumed by typescript (ts_project from rules_nodejs). rules_proto_grpc uses grpc_tools_node_protoc_plugin from the grpc-tools package to build a js_grpc_node_library. Building a js_grpc_node_library from a file (hello.proto) with an optional field results in the following error message:
hello.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-grpc_node_plugin hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--grpc_node_plugin_out:
Reproduction steps
Use js_grpc_node_library to compile a proto with an optional field. For example:
hello.proto:
syntax = "proto3";
package hello.proto;
message Hello {
optional string greeting = 1;
}
BUILD:
proto_library(
name = "hello_proto",
srcs = glob(["*.proto"]),
)
js_grpc_node_library(
name = "hello_js_grpc",
protos = [":hello_proto"],
)
Environment
- OS: Linux Ubuntu 20.04 amd64
- Node version: 16.12
- Node installation method: bazel rules_nodejs
- [email protected] (https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/js/requirements/package.json#L5)
This should already work. This was previously reported in #1717, and I made the fix for the plugin in #1725, and then that change was published in version 1.11.1.