Repository navigation
[59_maintenance] fix(arrow-schema): validate UnionFields when deserializing - #11672
Merged
Merged
Conversation
…11638) - Closes apache#11576. `UnionFields` derived `Deserialize`, so deserializing could build a value with duplicate or negative type ids, skipping the checks that `Serialize` is still derived (transparent), but `Deserialize` is now implemented by hand: it reads the same sequence of `(type_id, field)` pairs and builds the value with `UnionFields::try_new`, returning a serde error if validation fails. The wire format doesn't change, so anything serialized before still deserializes as long as it was valid. I kept serde rather than removing it, since `DataType` (and therefore `Field` and `Schema`) derive serde and need `UnionFields` to support it. Yes, two new tests in `fields.rs` (behind the `serde` feature, using `postcard` like the existing `Field` serde tests): a round trip of a valid `UnionFields`, and deserializing input with a duplicate type id and with a negative type id, both of which now fail. The second test fails without this change. Deserializing an invalid `UnionFields` (or a `DataType::Union` containing one) now returns an error instead of succeeding. AI disclosure: I used an AI coding assistant to write the change, the tests and this description, and I reviewed all of it. --------- Co-authored-by: ump45nose <ump45nose@users.noreply.github.com>
UnionFields when deserializing (#11638)UnionFields when deserializing
4 of 5 tasks
Contributor
Author
|
including audit fix as part of this PR instead of separate (#11674) since its just a |
Jefffrey
marked this pull request as ready for review
October 18, 2026 13:01
# Conflicts: # arrow-schema/src/fields.rs
alamb
approved these changes
Oct 19, 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.
UnionFieldswhen deserializing #1163859.3.2(October 2026) #11664Cherry-pick of a2b405f