Repository navigation
fix: accept repeated NullValue elements in ProtoJSON - #2373
Merged
alexander-fenster merged 1 commit intoJul 7, 2026
Merged
alexander-fenster merged 1 commit into
alexander-fenster merged 1 commit into
Conversation
alexander-fenster
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProtoJSON currently rejects
nullelements in repeatedgoogle.protobuf.NullValuefields before enum conversion runs.Repeated
nullelements are generally rejected, butgoogle.protobuf.NullValueis the documented exception because its JSON representation isnull. This change allows repeatedgoogle.protobuf.NullValueelements to reach the existingreadEnumhandling, which already convertsnulltoNULL_VALUE.Behavior
Before this change:
throws:
After this change, the same input parses as:
and serializes back to:
Ordinary repeated
nullelements remain rejected.Tests
Added regression coverage in
tests/api_protojson.jsfor repeatedgoogle.protobuf.NullValuefields.The test extends the existing
test.NullMsgfixture with:It then verifies both supported well-known-type root paths already used by the ProtoJSON tests:
.protorootFor each root, the test checks both directions:
fromJsonacceptsnullValues: [null, null]and parses it as[0, 0]toJsonserializes[0, 0]back asnullValues: [null, null]This specifically covers the bug where repeated
nullelements were rejected before the existingreadEnumhandling could convertgoogle.protobuf.NullValuefromnulltoNULL_VALUE.Existing tests continue to cover the general rule that ordinary repeated
nullelements are rejected, so this change only adds the documentedgoogle.protobuf.NullValueexception.