-
Notifications
You must be signed in to change notification settings - Fork 634
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
ProtoBuf serialization incorrect behavior #2888
Comments
1.Can't reproduce val bytes = byteArrayOf(9)
val message = ProtoBuf.decodeFromByteArray<ProtobufMessage<Int>>(bytes)
assertTrue { bytes.contentEquals(ProtoBuf.encodeToByteArray(message)) } // Fails Throws decoding error
|
3.Is not a bug. As a result, different source messages may correspond to the same decoded object. At the same time, kotlinx serialization always encodes the shortest version, so the original message and the encoded one are different. In this case, the original message contains fields with numbers 2012 and 15, which are not in the kxSerialization descriptor |
2.An empty list is being encoded now for packed repeated fields, this should be removed. |
3.Related task #2908 |
Closed as processed |
0. Setup
We will use the following structure of a Message:
It is slightly modified version of
Value
: added necessary annotations, unified types of lists and maps, added default value.1. Empty messages can be decoded from various sources
If we try to deserialize some strings we will get empty message even if input wasn't empty.
2. Equal messages are encoded differently depending on type
If we try to serialize message with default values inclusion that is based on strings and message that is based on integers, we will get different results. And it works for all non-primitive and primitive types.
3. Decoding-encoding transformation is not an identity
For some not empty messages we can find byte sequence that will be decoded as a message that encodes into a different byte array.
4. Null cannot be assigned to a field with default value
If a field has default value you can't assign null to it. Even if null is default value, even if encodeDefaults is false
Bugs are found by fuzzing team @ PLAN Lab
Environment
The text was updated successfully, but these errors were encountered: