Ignore null lists in MessageJsonAdapter#fromJson
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
In MessageJsonAdapter#fromJson, we ignore null values with if (value == null) continue. But if the deserialized value is a List<T?> whose some element is null, we still call fieldBinding.set(builder, value).
Later, when the T message is built, immutableCopyOf("…", list) checks require(null !in result) and throws an IllegalArgumentException because the list contains a null entry.
Is it okay to open a PR that updates fromJson to skip lists where every element is null, or to only include non-null elements?
EDIT: I initially thought we could simply remove nulls, but there are cases—like repeated google.protobuf.NullValue—where null is officially permitted.
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 at MessageJsonAdapter#fromJson and trace how deserialized lists are passed to fieldBinding.set when they contain null elements. Check the existing handling of repeated google.protobuf.NullValue before deciding the intended behavior, then add regression coverage showing that valid null values remain supported and other null-list cases no longer fail during message construction.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100