Skip to content

Fix NPE in Options.retainAll when map option entry omits value#3536

Open
jhansche wants to merge 1 commit intosquare:masterfrom
jhansche:fix-null-option-values
Open

Fix NPE in Options.retainAll when map option entry omits value#3536
jhansche wants to merge 1 commit intosquare:masterfrom
jhansche:fix-null-option-values

Conversation

@jhansche
Copy link
Contributor

@jhansche jhansche commented Mar 10, 2026

Map option entries may omit 'value' when the value type's default is desired. This is common in OpenAPI v2 annotations, e.g. a security requirement that needs bearer auth but no scopes:

security: { security_requirement: { key: "bearer" } }

Wire's canonicalizeValue correctly produces null for the missing value, but gatherFields and retainAll assumed non-null values everywhere, crashing with NPE during schema pruning. Fix by accepting nullable values: make retainAll's parameter Any?, add an o == null -> null branch, and remove unnecessary !! operators on map/list iteration variables.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Map option entries may omit 'value' when the value type's default is
desired. This is common in OpenAPI v2 annotations, e.g. a security
requirement that needs bearer auth but no scopes:

  security: { security_requirement: { key: "bearer" } }

Wire's canonicalizeValue correctly produces null for the missing value,
but gatherFields and retainAll assumed non-null values everywhere,
crashing with NPE during schema pruning. Fix by accepting nullable
values: make retainAll's parameter Any?, add an o == null -> null branch,
and remove unnecessary !! operators on map/list iteration variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jhansche
Copy link
Contributor Author

Sorry I missed it earlier: CLA has been signed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant