Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Reject null elements in ordinary repeated enums in both JSON parse modes. Use explicit canonical NullValue metadata to retain valid null elements and canonical repeated output, including older generated bindings and closed collections. Preserve unknown numeric values and unrelated field behavior.
vanderbr
force-pushed
the
fix/repeated-enum-null
branch
from
November 18, 2026 23:27
07c7079 to
1782868
Compare
This branch has not been deployed
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.
An ordinary repeated open enum currently accepts
{"values":[null]}and silently converts the element to enum value zero. Reject null elements in both strict parsing andignore_unknown_enum_valuesmode, as required by the ProtoJSON null rules. A null whole field still means an empty collection, and lenient filtering of unknown names and preservation of unknown numbers are unchanged.A defaulted
Enumeration::IS_NULL_VALUEmarker preserves the explicit exception for canonicalgoogle.protobuf.NullValueinput. Codegen emits it only for that exact protobuf type; an ordinary enum with aNULL_VALUEcase does not qualify. Existing enum implementations continue to compile. Existing generated messages using the updated canonical WKT provider need no regeneration; external or vendored NullValue providers need regeneration or explicit metadata.This is independent of the diagnostics work in #830 and #832. It overlaps the repeated-field portion of #806, which introduces dedicated NullValue helpers across field shapes; the generic repeated-helper changes here also support existing generated bindings. Scalar, optional and map behavior, compiler policy and dependency pins remain unchanged. Unknown enum numbers retain numeric serialization. Release preparation must advance the canonical WKT crate's minimum runtime requirement to the release containing the marker; version changes remain part of the release process.
Regression coverage includes strict/lenient parsing from JSON text and
serde_json::Value, first and later null elements, same-named impostor enums, Vec/custom collections, handwritten enum implementations, the exact codegen identity boundary, owned/view parity, and frozen pre-change bindings. The ordinary-enum rejection test failed on upstream main before the fix. Checked-in WKT, option and bootstrap bindings were regenerated. Within that regeneration diff, only the canonical NullValue marker changes.Canonical
NullValuezero variants serialize as JSON null in repeated collections, including legacy generated helper calls. Closed collections accept a null element only with the explicit marker and a declared zero variant; an inconsistent handwritten marker is rejected. Other enums, unknown numbers and non-human-readable serialization preserve their behavior.Validation:
The external protobuf conformance suite was not rerun for this follow-up.