Skip to content

Commit 070da0e

Browse files
committed
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.
1 parent 375e379 commit 070da0e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

spec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ These limits apply for messages generated by both COs and plugins.
386386
* A `repeated` or `map` field listed as `REQUIRED` MUST contain at least 1 element.
387387
* A field noted as `OPTIONAL` MAY be specified and the specification SHALL clearly define expected behavior for the default, zero-value of such fields.
388388

389+
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).
390+
389391
### Error Scheme
390392

391393
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).

0 commit comments

Comments
 (0)