fix(hql): DROP operation on empty traversals #670
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a runtime error in DROP operations when attempting to drop non-existent nodes, ensuring graceful handling of empty traversals.
Problem
Queries like
DROP N<NodeType>(id)on non-existent IDs failed with "Conversion error: Incorrect Type: Empty" because drop_traversal did not handle TraversalValue::Empty returned by collect_to_obj().Solution
Added
TraversalValue::Empty => Ok(()), in the match statement of drop_traversal. This treats empty traversals as successful no-ops.Related Issues
None
Checklist when merging to main
rustfmthelix-cli/Cargo.tomlandhelixdb/Cargo.tomlAdditional Notes
Greptile Overview
Updated On: 2025-10-24 19:24:02 UTC
Greptile Summary
Fixed runtime error when attempting to DROP non-existent nodes by adding
TraversalValue::Empty => Ok(())case to the match statement indrop_traversal().TraversalValue::EmptyImportant Files Changed
File Analysis
TraversalValue::Emptycase indrop_traversalto gracefully handle dropping non-existent nodes; minor formatting fixes appliedSequence Diagram
sequenceDiagram participant Client participant HQL participant drop_traversal participant collect_to_obj participant Storage Client->>HQL: DROP N<NodeType>(non_existent_id) HQL->>collect_to_obj: Query for node by ID collect_to_obj->>Storage: Fetch node Storage-->>collect_to_obj: No results found collect_to_obj-->>HQL: TraversalValue::Empty HQL->>drop_traversal: Process traversal items alt Empty traversal (after fix) drop_traversal-->>HQL: Ok(()) - no-op HQL-->>Client: Success else Empty traversal (before fix) drop_traversal-->>HQL: ConversionError HQL-->>Client: Error: "Incorrect Type: Empty" end