Skip to content

fix: validate embedding bytes length in bytes_to_embedding#44

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-141
Open

fix: validate embedding bytes length in bytes_to_embedding#44
echobt wants to merge 1 commit intomainfrom
fix/issue-141

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 20, 2026

Description

This PR addresses an issue where bytes_to_embedding would silently ignore trailing bytes that do not form a complete 4-byte chunk. This behavior could mask data corruption issues.

Changes

  • Added a debug_assert! to validate that the input byte slice length is divisible by 4.
  • Added unit tests to verify valid inputs and ensure invalid inputs trigger the assertion (panic in debug mode).

Verification

  • Added test_bytes_to_embedding_truncation which expects a panic when input length is invalid.
  • Added test_bytes_to_embedding_valid to ensure correct functionality for valid inputs.
  • Ran cargo test and confirmed all tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant