Skip to content

ProtoBuf cannot deserialize the Map from rs/prost if its value equals the default value #3113

@zhangz1han

Description

@zhangz1han

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions