Skip to content

feat: not found errors with suggestions#5830

Draft
wjones127 wants to merge 3 commits intolance-format:mainfrom
wjones127:error-suggestions
Draft

feat: not found errors with suggestions#5830
wjones127 wants to merge 3 commits intolance-format:mainfrom
wjones127:error-suggestions

Conversation

@wjones127
Copy link
Contributor

Closes #5642

@github-actions github-actions bot added enhancement New feature or request python labels Jan 27, 2026
@github-actions
Copy link
Contributor

PR Review: feat: not found errors with suggestions

P0 Issues (Critical Bugs)

1. Duplicate code and unreachable statements in rust/lance-index/src/lib.rs

Lines 496-502 in the diff show duplicated code that will never execute:

Err(Error::invalid_input(error_msg, location!()));  // This returns Err but result is ignored
lance_core::levenshtein::find_best_suggestion(value, &valid_index_types);  // Unreachable
let mut error_msg = format!("invalid index type: {}", value);  // Unreachable - redeclares error_msg
if let Some(suggestion) = suggestion {  // Uses wrong suggestion variable
    error_msg = format!("{}. Did you mean '{}'?", error_msg, suggestion);
}
Err(Error::invalid_input(error_msg, location!()))

The first Err() statement returns early but the result is discarded (statement ends with ;). The code after it is dead code. The fix should remove lines 496-501 and keep only the final Err return.

2. Python test assertions are inside with pytest.raises() block (python/python/tests/test_dataset.py)

Lines 55-61 and 64-70 in the test show assertions placed inside the with pytest.raises() block:

with pytest.raises(FieldNotFoundError) as e:
    ds.scanner(columns=["non_existent_field"]).to_table()
    # These assertions never execute because the line above raises
    expected = (...)
    assert str(e.value) == expected

The assertions after to_table() will never run because the exception is raised. Move assertions outside the with block.

3. Test file committed to repo: rust/test_error_suggestions.rs

This appears to be a development test file that shouldn't be committed. It's not part of any crate and won't compile as-is (wrong imports, missing dependencies).

P1 Issues (Should Fix)

4. Levenshtein tests have incorrect assertions (rust/lance-core/src/levenshtein.rs)

Line 425-426:

assert_eq!(levenshtein_distance("vector", "vector"), 0);
assert_eq!(levenshtein_distance("vector", "vector"), 1);  // Should be different inputs

Both lines compare "vector" to "vector" but expect different results (0 and 1). The second line appears to be a copy-paste error - likely should test "vector" vs "vactor" or similar.

5. Unused error type added to lance-namespace (rust/lance-namespace/src/error.rs)

TableColumnNotFoundWithSuggestionError and NamespaceError::TableColumnNotFoundWithSuggestion are added but never used in the codebase. Consider removing until needed, or add the actual usage.

6. Result type alias change may break downstream code (rust/lance-core/src/error.rs)

Line 299: pub type Result<T, E = Error> = std::result::Result<T, E>;

This changes Result<T> to have a default second generic parameter. While backwards compatible in most cases, this could cause issues if any code relies on the exact type signature.

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

Labels

enhancement New feature or request python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance not found errors with suggestions

2 participants