Repository navigation
fix(arrow-array): strip trailing bytes in values data when constructing FixedSizeBinaryArrays - #12410
Conversation
| )); | ||
| } | ||
|
|
||
| let required_len = len * value_size; |
There was a problem hiding this comment.
super super nit: replace this with a checked mul
lets avoid the 1 line follow up pr 😅
There was a problem hiding this comment.
Replaced len * value_size with len.checked_mul(value_size) in FixedSizeBinaryArray::try_new_with_len (arrow-array/src/array/fixed_size_binary_array.rs) in the latest commit.
Re-verified with cargo fmt -p arrow-array -- --check, cargo clippy -p arrow-array --lib --tests -- -D warnings, and cargo test -p arrow-array --lib (765 passed, 0 failed, 1 ignored).
There was a problem hiding this comment.
is this error case strictly necessary? arent we bounded by the above check
in that we cant overflow this multiplication if we've reached this point?
side note: it is not necessary to restate youve run the test suite, the CI would speak for itself
There was a problem hiding this comment.
Good catch — when value_size != 0, the values.len() / value_size != len check above guarantees len * value_size <= values.len() <= usize::MAX, and when value_size == 0, the product is always 0. Removed the unreachable error branch in a56c2f6 (using checked_mul(value_size).expect(...) to match From<ArrayData>).
|
Yes, there is a human owner behind this account — I use AI coding agents as part of my workflow to find, implement, and test bug fixes across open-source repos, and I verify the changes and test suites locally ( Fully understand if |
…Array::try_new_with_len
Jefffrey
left a comment
There was a problem hiding this comment.
it would be a good idea to document this new behaviour in appropriate places
Yes, there is a human owner behind this account — I use AI coding agents as part of my workflow to find, implement, and test bug fixes across open-source repos, and I verify the changes and test suites locally (
arrow-array,arrow-select, and the enabled fork CI workflow on this branch).Fully understand if
arrow-rsprefers human-authored-only submissions or wants additional scrutiny on the fix inarrow-array/src/array/fixed_size_binary_array.rs; happy to address any technical review feedback on#12410or close it if you'd rather not take it.
we are fine with AI usage; however we are under pressure from increasing bot accounts which submit PRs to a wide range of repos, giving zero confidence the author has given proper care and consideration to each and every one, which pushes all of the burden onto us maintainers. im fine with proceeding with this PR, but i expect good faith effort from an actual human being
|
Updated in |
…chable overflow error
FixedSizeBinaryArrays

Which issue does this PR close?
FixedSizeBinary::value_datacan return trailing bytes #12409Rationale for this change
FixedSizeBinaryArray::try_newandFixedSizeBinaryArray::try_new_with_lenallow constructing an array from aBufferwith trailing remainder bytes (tested intest_constructorsfor a 10-byte buffer withvalue_length = 3yieldinglen() == 3), but stored the unslicedBuffer. As a result,FixedSizeBinaryArray::value_data()andvalues()exposed trailing bytes pastlen * value_size, causing callers such asFixedSizeBinaryBuilder::append_arrayto append extra non-element bytes and shift subsequent elements.What changes are included in this PR?
FixedSizeBinaryArray::try_new_with_leninarrow-array/src/array/fixed_size_binary_array.rsto slicevaluesto0..len * value_sizewhenevervalues.len() > len * value_size, matching the invariant already maintained byFrom<ArrayData>,slice(), andnew_unchecked().value_data(),values(),to_data(),into_parts(), andFixedSizeBinaryBuilder::append_arraywhen the sourceFixedSizeBinaryArrayis constructed from a buffer containing trailing bytes.Are these changes tested?
Yes. Added unit tests
test_try_new_strips_trailing_bytes(arrow-array/src/array/fixed_size_binary_array.rs) andtest_fixed_size_binary_builder_append_array_trailing_bytes(arrow-array/src/builder/fixed_size_binary_builder.rs) covering construction with trailing buffer bytes and appending intoFixedSizeBinaryBuilder, and ranarrow-arrayandarrow-selecttests alongsiderustfmtandclippy.Are there any significant user-facing changes?
No.
FixedSizeBinaryArray::value_data(),values(),to_data(), andinto_parts()now expose only thelen * value_sizebytes belonging to the array rather than trailing buffer padding bytes.AI usage disclosure
An LLM coding assistant helped inspect callers, draft the fix and unit tests, and run local
cargoverification, with all changes reviewed and verified before submission.