Map Adapter cannot handle Value whose representation can be zero bytes
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
Subj
If you use message like:
message ValidZeroPayload {
float distance_meters = 2;
reserved 1;
}
Wire will choke on parsing map with value initialized as:
ValidZeroPayload {
distance_meters: 0.0
}
That's because it will be encoded as zero bytes due to zero being treated as non-presence in case of integers and floats
Therefore it triggers this check to fail:
https://github.com/square/wire/blob/master/wire-runtime/src/commonMain/kotlin/com/squareup/wire/ProtoAdapter.kt#L812
Even though message itself is legit in protobuf 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in wire-runtime/src/commonMain/kotlin/com/squareup/wire/ProtoAdapter.kt at the check around line 812, and reproduce the issue with the ValidZeroPayload protobuf example. Verify that a map value whose valid protobuf representation is zero bytes can be parsed successfully, while malformed input remains rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100