Skip to content
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

Found and fixed a bug in FieldDescriptor.Cardinality implementation #270

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented Apr 6, 2024

Updates the descriptor implementation tests to check a few other attributes, which uncovered a bug in the Cardinality method, which should report "required" for editions fields where features.field_presence == LEGACY_REQUIRED.

@jhump jhump marked this pull request as ready for review April 6, 2024 03:20
@jhump jhump requested review from timostamm and emcfarlane April 6, 2024 12:43
@@ -1047,6 +1047,12 @@ func (f *fldDescriptor) Cardinality() protoreflect.Cardinality {
case descriptorpb.FieldDescriptorProto_LABEL_REQUIRED:
return protoreflect.Required
case descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL:
if f.Syntax() == protoreflect.Editions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a comment that explaining that FieldDescriptorProto.label is always set to LABEL_OPTIONAL for editions.

@jhump jhump enabled auto-merge (squash) April 8, 2024 13:21
@jhump jhump merged commit a556a4b into main Apr 8, 2024
8 checks passed
@jhump jhump deleted the jh/fix-cardinality-in-descriptor-impl branch April 8, 2024 13:23
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Apr 12, 2024
…ufbuild#270)

Updates the descriptor implementation tests to check a few other
attributes, which uncovered a bug in the `Cardinality` method, which
should report "required" for editions fields where
`features.field_presence == LEGACY_REQUIRED`.

(cherry picked from commit a556a4b)
kralicky pushed a commit to kralicky/protocompile that referenced this pull request Apr 12, 2024
…ufbuild#270)

Updates the descriptor implementation tests to check a few other
attributes, which uncovered a bug in the `Cardinality` method, which
should report "required" for editions fields where
`features.field_presence == LEGACY_REQUIRED`.

(cherry picked from commit a556a4b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants