New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace "label" check with "cardinality" check #2927
Conversation
… and wire-json-compatible variants for v2
… by cardinality check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved given we keep the FIELD_SAME_LABEL
test (copy/paste)
… new rule correctly
…report errors in triplicate
@bufdev, I added it back. And then I was considering what you said a little more about how it's fine to maybe report multiple errors for the same change... So I added two more commits. What those last two commits do is to make the deprecated So the question is: is this better for "v1" and backwards compatibility? I think it is. Without those last two commits, the behavior for "v1" is that it could start complaining about changes when using WIRE or WIRE_JSON categories that aren't really incompatible -- things that it did not complain about before because of the subtle differences between What do you think is better? Should I back those last two commits out? |
The name change is because some of the values of "cardinality" differ from the label field in
FieldDescriptorProto
. Also, in "editions" some of these values are configured via afield_presence
feature, not the field label.Previously, I mentioned replacing "label" checks with two separate checks: "cardinality" and "field presence". But I decided to keep them together in a single check because it makes the wire and JSON compatibility story easier IMO.
So the values of "cardinality" are as follows:
For wire format compatibility, repeated and map are compatible as are the two kinds of optional fields. But for JSON format, repeated and map are not compatible since one uses JSON arrays and the other JSON objects/maps.
This also updates the oneof-related checks to ignore synthetic oneofs. Synthetic oneofs are a side effect of proto3-optional fields. Changes to them will now be covered by the cardinality check, which can now distinguish between optional fields with implicit vs explicit field presence (proto3-optional fields provide explicit presence in proto3).