python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

Loosing repeated sub elements from list when only attribute is set to 0

Open alk-sramond opened this issue 3 years ago • 0 comments

We have noticed that we are loosing part of a protobuf when the only attribute of an element is set to 0.

Tested: on the last 2.0.0b4

Example:

Protobuf

message Element {
  uint64 id = 1;
}

message ParentElement {
  string name = 1;
  repeated Element elems = 2
}

Python code:

from the.package import ParentElement, Element

el = ParentElement(name="test", elems=[Element(id=0), Element(id=42)])

bytes_el = bytes(el)

ParentElement().parse(bytes_el)

>>> ParentElement(name="test", elems=[Element(id=42])

# Element(id=0) is gone

Is this an expected behaviour?

alk-sramond avatar May 17 '22 15:05 alk-sramond