Closed
Description
Given the definition:
syntax = "proto2";
package cockroach.build;
option go_package = "build";
import "gogoproto/gogo.proto";
// Info describes build information for this CockroachDB binary.
message Info {
optional string go_version = 1 [(gogoproto.nullable) = false];
optional string tag = 2 [(gogoproto.nullable) = false];
optional string time = 3 [(gogoproto.nullable) = false];
optional string revision = 4 [(gogoproto.nullable) = false];
optional string cgo_compiler = 5 [(gogoproto.nullable) = false];
optional string platform = 6 [(gogoproto.nullable) = false];
optional string distribution = 7 [(gogoproto.nullable) = false];
optional string type = 8 [(gogoproto.nullable) = false];
// dependencies exists to allow tests that run against old clusters
// to unmarshal JSON containing this field. The tag is unimportant,
// but the field name must remain unchanged.
//
// alternatively, we could set jsonpb.Unmarshaler.AllowUnknownFields
// to true in httputil.doJSONRequest, but that comes at the expense
// of run-time type checking, which is nice to have.
optional string dependencies = 10000;
}
The generated message behaves incorrectly:
$ node
> var protos = require('./src/js/protos');
undefined
> r = new protos.cockroach.build.Info()
Info {}
> r.go_version
''
This should return null, not empty string. Note that in protobuf 3 it should return empty string, since primitives are non-nullable in protobuf 3.
The typescript definitions are also incorrect with respect to the nullability of these attributes.