Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Apply opt-in cleanup consistently to typed and reflective merges, including size and resource-limit failures. Preserve the original error and normal partial-merge behavior when disabled. Add a reversible builder alongside the existing shortcut and getter. Cover custom cleanup hooks, buffer consumption, nested containers, oneofs, MessageSet and registered extensions, and document logical cleanup without memory-wiping or rewind guarantees.
vanderbr
force-pushed
the
reallyme/clear-on-merge-error
branch
from
November 18, 2026 02:46
29641c9 to
4aedbad
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.
Failed merges can leave old fields and partially decoded values in the destination. Callers that must discard that state currently need to clear it on every error path.
Add an opt-in policy shared by
DecodeOptions::merge,DecodeOptions::merge_from_slice, andDynamicMessage::merge_with_options, including errors from size rejection before parsing, recursion, unknown-field and element-memory limits. Typed merges callMessage::clearexactly once after an error. Reflective merges remove all fields, registered extensions and unknown fields while retaining the descriptor pool and message type. Default and successful merge behavior is unchanged.clear_on_merge_error()enables the policy,with_clear_on_merge_error(bool)enables or disables it on an existing or cloned configuration, andclears_on_merge_error()reports its state. The slice wrapper delegates to the buffer wrapper so they share the same failure policy.Clearing removes logical state; wiping depends on the typed message's own
clearimplementation. Reflective cleanup does not wipe memory, and backing storage may be retained. Caller input is not wiped and consumed buffer positions are not rewound. Typed decode methods do not apply this policy. Reflectivedecode_with_optionsdelegates to merge and applies it to its temporary destination on error; it still returns no message and adds no wiping guarantee.Validation: 4,349 workspace tests, strict all-target/all-feature Clippy, formatting and strict rustdoc pass on the pinned toolchain. Focused Rust 1.75 tests pass using a separate compatible validation lockfile; runtime/reflection host and WASM no_std checks also pass. Regressions cover nested messages, lists/maps, late map normalization, oneofs, registered extensions/groups, MessageSet, limits, cleanup-hook dispatch, clone configuration, fragmented-buffer consumption, empty input and reuse. A separate bounded probe passed 394,758 enabled/disabled comparisons across unrolled, table and reflective decoding, checking errors, successful values and typed buffer cursors.
Release the descriptor changes with a runtime containing the new getter and raise the runtime dependency minimum as part of that coordinated release. Versions, lockfile, MSRV and toolchain preparation remain separate from this feature change.
Related to #822.