ProtoBuf cannot deserialize the Map from `rs/prost` if its value equals the default value
Describe the bug
For mutableMapOf("key" to ""),
KotlinX Serialization ProtoBuf encodes both the key and value. Serialization and deserialization are fine.
However, in rs/prost, because the value is equal to the default value, it is omitted during encoding, so the final binary only contains the key.
When KotlinX Serialization ProtoBuf attempts to deserialize it, it throws a SerializationException: Element 'value' is missing.
rs/prost believes their implementation conforms to the specification: tokio-rs/prost/issues/99
Environment
- Kotlin version: 2.2.21
- Library version: 1.9.0
Original discussion suggests that not writing a value in a map is to-spec, but contradicts most default proto implementations in other languages. It's an optional/default problem again, but I think it makes sense to fix it on our side. Although, I do not know if they do this optimization for non-primitives as well; in that case, we won't be able to restore them.