Skip to content

MOD-14632 Eliminate panics across codebase#1530

Open
AvivDavid23 wants to merge 2 commits intomasterfrom
MOD-14632
Open

MOD-14632 Eliminate panics across codebase#1530
AvivDavid23 wants to merge 2 commits intomasterfrom
MOD-14632

Conversation

@AvivDavid23
Copy link
Copy Markdown
Contributor

@AvivDavid23 AvivDavid23 commented Mar 31, 2026

Trying to eliminate as much a possible from all the panic and unwanted unwraps in. the codebase.

  • Currently, for SelectValue trait getters, returning an Option to align we current solution of get_key, get_values, etc..
  • For some unexpected branches, for example, .len() call returned None on a String value type, a debug_assert will be attached to each of such cases.
  • Add cargo clippy to the CI

Note

Medium Risk
Touches core JSONPath evaluation and RedisJSON command/FFI plumbing by changing SelectValue getter semantics and adding defensive None/error handling, which could subtly change behavior for edge cases. The change reduces crash risk but needs careful review for any new Null/error returns in previously-panicking paths.

Overview
Eliminates panics/unwrap() in JSONPath and RedisJSON hot paths by changing SelectValue scalar getters (get_str/as_str/get_bool/get_long/get_double) to return Option and updating callers to propagate None as not comparable / null / error instead of crashing.

JSONPath compilation and evaluation is made more defensive (missing parse nodes/filters/ranges now short-circuit with trace! logging; container iteration macros tolerate absent items()/values(); tracked-path invariants are asserted via explicit expect). RedisJSON RDB loading and C API entrypoints now return structured errors/null on invalid inputs rather than panicking, and numeric/object errors are centralized via new err_not_a_number/err_bad_object helpers.

CI now runs cargo clippy (with warnings denied and panic/todo/unimplemented lints) via a new reusable flow-clippy.yml wired into event-ci.yml.

Written by Cursor Bugbot for commit 2a4c067. This will update automatically on new commits. Configure here.

@AvivDavid23 AvivDavid23 requested a review from TalBarYakar March 31, 2026 12:13
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 52.95455% with 207 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.08%. Comparing base (9c66b9a) to head (2a4c067).

Files with missing lines Patch % Lines
json_path/src/json_path.rs 34.86% 99 Missing ⚠️
redis_json/src/c_api.rs 0.00% 39 Missing ⚠️
redis_json/src/key_value.rs 75.94% 19 Missing ⚠️
json_path/src/json_node.rs 59.37% 13 Missing ⚠️
json_path/src/select_value.rs 76.08% 11 Missing ⚠️
redis_json/src/commands.rs 74.41% 11 Missing ⚠️
redis_json/src/ivalue_manager.rs 66.66% 10 Missing ⚠️
redis_json/src/manager.rs 50.00% 3 Missing ⚠️
redis_json/src/backward.rs 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1530      +/-   ##
==========================================
- Coverage   76.84%   75.08%   -1.77%     
==========================================
  Files          15       15              
  Lines        4004     4218     +214     
==========================================
+ Hits         3077     3167      +90     
- Misses        927     1051     +124     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant