-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ENH] Disallow empty string ids during add #4488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Disallow Empty String IDs During Record Addition This PR adds validation to the Rust codebase to prevent empty string IDs (zero-length) when adding records to Chroma. It introduces a new error type EmptyId and adds a validation check in the to_records function to reject IDs without any characters. Key Changes: Affected Areas: This summary was automatically generated by @propel-code-bot |
Vec<(String, chroma_types::UpdateMetadataValue)>, | ||
>(ids, Some(embeddings), None, None, None, Operation::Add); | ||
assert!(matches!(result, Err(ToRecordsError::EmptyId))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[TestCoverage]
You should add a test case for IDs containing valid non-empty values (including whitespace or unusual Unicode), to ensure is_empty()
is the correct check and not overly restrictive. This will prevent regressions if the ID requirements change.
rust/frontend/src/impls/utils.rs
Outdated
let result = super::to_records::< | ||
chroma_types::UpdateMetadataValue, | ||
Vec<(String, chroma_types::UpdateMetadataValue)>, | ||
>(ids, Some(embeddings), None, None, None, Operation::Add); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BestPractice]
Since use super::*;
is already present (line 100), the super::
prefix in super::to_records
is redundant. You can call to_records
directly.
250973a
to
228f284
Compare
228f284
to
896f24f
Compare
@@ -47,6 +49,9 @@ pub(crate) fn to_records< | |||
let mut records = Vec::with_capacity(len); | |||
|
|||
for id in ids { | |||
if id.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems inconsistent with the rest of our code where we use #[validate]
Description of changes
This PR disallows setting an empty string for an ID
#4346
Test plan
How are these changes tested?
pytest
for python,yarn test
for js,cargo test
for rustDocumentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?
This PR adds validation to prevent empty string IDs during the record addition process. It modifies the Rust codebase to reject IDs with zero characters by adding a new error type and appropriate validation check, addressing issue #4346.
Key Changes:
• Added a new
EmptyId
error type to theToRecordsError
enum• Added validation to check for empty IDs in the
to_records
function• Added comprehensive test cases to verify the validation behavior
Affected Areas:
• rust/frontend/src/impls/utils.rs
This summary was automatically generated by @propel-code-bot