square / square/wire

Nullable annotations are mostly meaningless

Open
#564 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

To not run into compatibility problems every single field in a proto ends up being optional, ergo annotated @Nullable. Even if the person writing the proto knows a field cannot be null, theres no way to communicate that and generate Messages with appropriate nullability annotations. The nullable annotations end up being pretty useless because theres no way to know if a field is being passed as null, or not being passed at all and turned into null. Ideally when lint warns me about a field being nullable I know that means it could be passed to me as null and I need to do null logic, but right now I just ignore most warnings because the value will never actually be null.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating the proto-to-Message generation path and the code that applies @Nullable annotations, then define how absent fields differ from explicitly null fields and what generated nullability should communicate; done means the semantics are specified and covered by generation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.