-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[ENH]: Error if source_key set but no ef #5751
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
[ENH]: Error if source_key set but no ef #5751
Conversation
|
Validate Adds client-side (Python) and server-side (Rust) guards so that a sparse-vector index cannot be created with a non-null Key Changes• Introduced Affected Areas• This summary was automatically generated by @propel-code-bot |
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
| .into(), | ||
| )); | ||
| } | ||
| if svit.config.source_key.is_some() && svit.config.embedding_function.is_none() { |
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.
[CriticalError]
Validation logic discrepancy between Python and Rust implementations:
Python validation (line 2053-2055):
if (config.source_key is not None
and config.embedding_function is None
and config.bm25 is not True):Rust validation (line 2284):
if svit.config.source_key.is_some() && svit.config.embedding_function.is_none() {The Rust validation is missing the bm25 check entirely. This means:
- Python:
SparseVectorIndexConfig(source_key="text", bm25=True)✅ passes validation - Rust: Same config ❌ fails validation
This will cause runtime failures when the Python client sends valid configs to a Rust server.
Fix the Rust validation:
if svit.config.source_key.is_some()
&& svit.config.embedding_function.is_none()
&& !svit.config.bm25.unwrap_or(false) {Context for Agents
[**CriticalError**]
Validation logic discrepancy between Python and Rust implementations:
**Python validation (line 2053-2055):**
```python
if (config.source_key is not None
and config.embedding_function is None
and config.bm25 is not True):
```
**Rust validation (line 2284):**
```rust
if svit.config.source_key.is_some() && svit.config.embedding_function.is_none() {
```
The Rust validation is missing the `bm25` check entirely. This means:
- Python: `SparseVectorIndexConfig(source_key="text", bm25=True)` ✅ passes validation
- Rust: Same config ❌ fails validation
This will cause runtime failures when the Python client sends valid configs to a Rust server.
**Fix the Rust validation:**
```rust
if svit.config.source_key.is_some()
&& svit.config.embedding_function.is_none()
&& !svit.config.bm25.unwrap_or(false) {
```
File: rust/types/src/validators.rs
Line: 284## Description of changes _Summarize the changes made by this PR._ - Improvements & Bug fixes - Errors if source_key is set but ef is not supplied. Both client and server side - New functionality - ... ## Test plan _How are these changes tested?_ Added unit-test - [x] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Migration plan None ## Observability plan None ## Documentation Changes None
This reverts commit 0d3bd2a.

Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
Added unit-test
pytestfor python,yarn testfor js,cargo testfor rustMigration plan
None
Observability plan
None
Documentation Changes
None