-
Notifications
You must be signed in to change notification settings - Fork 630
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
Implemented encoding null in key and value of a map in Protobuf #2910
base: dev
Are you sure you want to change the base?
Conversation
Also improved `null` encoding error messages. Resolves #2760
The open question is whether we want to allow encoding This change may also make the encoded messages incompatible with some decoders created using |
How will it look like? A value without a key? In that case, we possibly can decode it automatically into a |
@@ -37,7 +38,8 @@ internal abstract class ProtobufTaggedEncoder : ProtobufTaggedBase(), Encoder, C | |||
if (nullableMode != NullableMode.ACCEPTABLE) { | |||
val message = when (nullableMode) { | |||
NullableMode.OPTIONAL -> "'null' is not supported for optional properties in ProtoBuf" | |||
NullableMode.COLLECTION -> "'null' is not supported for collection types in ProtoBuf" | |||
NullableMode.COLLECTION -> "'null' is not supported as the value of collection types in ProtoBuf" | |||
NullableMode.LIST_ELEMENT -> "'null' is not supported as the value of a list element in ProtoBuf" |
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.
Is LIST_ELEMENT
added for the purpose of proper error message only? I do not see this string being tested anywhere
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.
Yes, only the accepted or not flag is sufficient to throw an error. The enumeration is created only for printong different messages
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.
Then add a test for this message pls
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.
Tests added
Each map declaration in protobuf structually is repeated field with Entry message
is the same as
see the protobuf doc Therefore, we can skip either the key or the value.
It's already implemented in this PR, see |
I think it is OK to have it if the message itself is not malformed |
Also improved
null
encoding error messages.Resolves #2760