-
Notifications
You must be signed in to change notification settings - Fork 0
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
Pass redis error to upstream instead of sending the generic FalkorDBE… #60
Conversation
…rror::ParsingArray
WalkthroughThe changes involve modifications to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
==========================================
- Coverage 84.91% 84.70% -0.22%
==========================================
Files 28 28
Lines 3899 3904 +5
Branches 3899 3904 +5
==========================================
- Hits 3311 3307 -4
- Misses 399 407 +8
- Partials 189 190 +1 ☔ View full report in Codecov by Sentry. |
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.
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/parser/mod.rs (1)
94-96
: Enhance function documentationConsider adding more details to the documentation, such as:
- Example usage
- Return value description
- Error cases description
// Parse a Redis response as a vector of Redis values // Redis response can be a vector of results or an error returned from redis +// Returns: +// - Ok(Vec<redis::Value>) if the response is an array +// - Err(FalkorDBError) containing the original Redis error if the response is a server error +// - Err(FalkorDBError::ParsingArray) for other invalid responses +// +// Example: +// ``` +// let response = redis_response_as_vec(value)?; +// for item in response { +// // Process each item +// } +// ```
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
src/error/mod.rs
(1 hunks)src/graph/query_builder.rs
(2 hunks)src/parser/mod.rs
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/graph/query_builder.rs
🔇 Additional comments (4)
src/error/mod.rs (2)
135-139
: LGTM! Clean implementation of error conversion.
The From
trait implementation correctly maps Redis errors to FalkorDBError::RedisError
, which aligns with the PR objective of passing Redis errors upstream instead of using generic errors.
135-139
: Verify consistent error handling across the codebase.
Let's ensure this new error conversion is being used consistently and that we're not still using generic errors for Redis errors elsewhere.
✅ Verification successful
Let me analyze the Redis error handling patterns from the output. I can see three files with Redis error handling:
src/error/mod.rs
: Contains the newFrom
implementationsrc/connection/mod.rs
: Has a custommap_redis_err
functionsrc/parser/mod.rs
: Has mixed error handling with both Redis errors and parsing errors
Let me verify if there are any other Redis-related error conversions or handling:
Redis error handling is consistent but could be simplified
The codebase shows a mixed pattern of Redis error handling:
- There's a dedicated
map_redis_err
function insrc/connection/mod.rs
that provides specialized handling for connection-related Redis errors - The new
From<redis::RedisError>
implementation insrc/error/mod.rs
provides a simpler conversion - Direct error conversions are used in various places (e.g., in
client/
modules)
While the error handling is technically consistent (all Redis errors are properly captured), it could be simplified:
- The
map_redis_err
function inconnection/mod.rs
provides more specific error mapping that's not available through the genericFrom
implementation - Multiple modules directly convert Redis errors to
FalkorDBError::RedisError
when they could use theFrom
implementation - No instances found of Redis errors being improperly handled or escaping the error boundary
Recommendation: Consider consolidating the specialized error mapping from map_redis_err
into the From<redis::RedisError>
implementation to provide a single, consistent way to handle Redis errors throughout the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for potential inconsistent Redis error handling
# Look for direct Redis error handling that might not use the new From implementation
rg -l "redis::RedisError" | while read -r file; do
echo "=== Checking $file for Redis error handling ==="
rg -A 3 "redis::RedisError|FalkorDBError::ParsingArray|FalkorDBError::RedisError" "$file"
done
# Look for potential places where we might still be using ParsingArray for Redis errors
rg -A 3 "ParsingArray.*redis"
Length of output: 2078
Script:
#!/bin/bash
# Search for any Redis-related error handling we might have missed
rg -A 3 "redis.*err|err.*redis" --ignore-case
# Look for any direct Redis crate usage that might involve error handling
rg "use redis::"
Length of output: 8867
src/parser/mod.rs (2)
97-104
: LGTM! Implementation aligns with PR objectives
The function correctly handles both successful array responses and server errors, properly propagating Redis errors upstream instead of wrapping them in a generic error type. This aligns well with the PR's objective of improving error granularity.
169-172
: LGTM! Good refactoring
The changes improve code maintainability by leveraging the redis_value_as_typed_string
helper function while maintaining proper error handling. The existing test coverage ensures the modification is safe.
…rror::ParsingArray
Summary by CodeRabbit
New Features
Bug Fixes
Chores