Skip to content

FixedSizeBinary::value_data can return trailing bytes #12409

Description

@Jefffrey

Describe the bug

When constructing a FixedSizeBinaryArray, if the given buffer bytes don't divide evenly by the value_size, we have trailing bytes which can be returned by APIs. For example:

    #[test]
    fn test123() {
        let array = FixedSizeBinaryArray::new(3, vec![0_u8; 10].into(), None);
        assert_eq!(array.len(), 3); // 3 * 3 = 9
        assert_eq!(array.value_data().len(), 10); // 1 trailing byte
    }

This test currently passes. This can be confusing, and can lead to bugs in other APIs. For example:

/// Appends all elements in array into the builder.
pub fn append_array(&mut self, array: &FixedSizeBinaryArray) -> Result<(), ArrowError> {
if self.value_length != array.value_length() {
return Err(ArrowError::InvalidArgumentError(
"Cannot append FixedSizeBinaryArray with different value length".to_string(),
));
}
let buffer = array.value_data();
self.values_builder.extend_from_slice(buffer);
if let Some(validity) = array.nulls() {
self.null_buffer_builder.append_buffer(validity);
} else {
self.null_buffer_builder.append_n_non_nulls(array.len());
}
Ok(())
}

  • Lines 102 & 103 assume that all bytes are part of the array; however if we have trailing bytes, these can be appended and corrupt the data of the builder

To Reproduce

No response

Expected behavior

Fix to ensure we strip trailing bytes, so we have a consistent view of only the bytes involved in the array

Additional context

No response

Willingness to contribute

I cannot contribute a fix for this bug at this time

Activity

  1. added theissue type on Nov 23, 2026
  2. added
    bug
    on Nov 23, 2026
  3. added a commit that references this issue on Nov 24, 2026
    6ec6d46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions