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

fix: proto3 optionals from base64 encoded proto descriptors #986

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

keejon
Copy link
Contributor

@keejon keejon commented Oct 30, 2024

This fixes deserialization of optionals in proto3 descriptors as they are represented by synthetic oneofs.

@keejon keejon force-pushed the keejon/fix-protobuf-optionals branch from 51cbe5f to 766d129 Compare October 30, 2024 15:16
This fixes  deserialization of optionals in proto3 descriptors as they are represented by synthetic oneofs.
@keejon keejon force-pushed the keejon/fix-protobuf-optionals branch from 766d129 to 7a3c839 Compare October 30, 2024 15:19
Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/karapace/protobuf
  serialization.py
Project Total  

This report was generated by python-coverage-comment-action

@keejon keejon marked this pull request as ready for review October 30, 2024 15:43
@keejon keejon requested review from a team as code owners October 30, 2024 15:43
Comment on lines +102 to +107
if is_proto3_optional:
# Every proto3 optional field is placed into a one-field oneof, called a "synthetic" oneof,
# as it was not present in the source .proto file.
# This will make sure that we don't interpret those optionals as oneof.
one_ofs[f.oneof_index] = None
fields.append(sf)
Copy link
Contributor

Choose a reason for hiding this comment

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

to be honest I don't really like the idea of marking the syntetic ones as None but I have no better ideas on how to keep the information in the type system 😄
Nice work! Thanks for the fix

Copy link
Contributor

@eliax1996 eliax1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@eliax1996 eliax1996 merged commit e6f39bf into main Oct 31, 2024
9 checks passed
@eliax1996 eliax1996 deleted the keejon/fix-protobuf-optionals branch October 31, 2024 08:41
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.

2 participants