From 070da0eb5334e68c99a1af25e80d225e97865af8 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 8 Nov 2018 10:29:12 +0100 Subject: [PATCH] doc: Add comment about scalars in proto3 GRPC proto3 docs states that all scalar fields have a default value, and that default values for scalars will not be transferred over the wire. This makes it impossible to know if a message had a field set in the first place, so even if a field is REQUIRED in the spec and it is set on send, it may not be present on the message. This is something that developers must be aware when writing plugins, as they should not be check for the presence of scalar REQUIRED fields on the message, as they'll only be present when the value is not the default. In this patch we add a comment at the beginning of the document for those who are not aware of this implementation detail of proto3. --- spec.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec.md b/spec.md index b34b14dc..bdf4dbe0 100644 --- a/spec.md +++ b/spec.md @@ -386,6 +386,8 @@ These limits apply for messages generated by both COs and plugins. * A `repeated` or `map` field listed as `REQUIRED` MUST contain at least 1 element. * A field noted as `OPTIONAL` MAY be specified and the specification SHALL clearly define expected behavior for the default, zero-value of such fields. +Scalar fields, even REQUIRED ones, will be defaulted if not specified, and any field set to the defaul value will not be serialized over the wire as per [proto3](https://developers.google.com/protocol-buffers/docs/proto3#default). + ### Error Scheme All CSI API calls defined in this spec MUST return a [standard gRPC status](https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto).