Skip to content

MOD-6722 Fix mutation ordering for array commands with recursive paths#1543

Open
AvivDavid23 wants to merge 1 commit intomasterfrom
MOD-6722
Open

MOD-6722 Fix mutation ordering for array commands with recursive paths#1543
AvivDavid23 wants to merge 1 commit intomasterfrom
MOD-6722

Conversation

@AvivDavid23
Copy link
Copy Markdown
Contributor

@AvivDavid23 AvivDavid23 commented Apr 9, 2026

Sort matched paths deepest-first before applying mutations in ARRPOP, ARRTRIM, and ARRINSERT. This prevents earlier mutations from invalidating later paths when using recursive descent expressions like $..* on nested arrays.


Note

Medium Risk
Changes mutation ordering for JSON.ARRPOP/JSON.ARRTRIM/JSON.ARRINSERT (including legacy variants), which can subtly affect command results for multi-path operations; adds tests to lock in the new behavior.

Overview
Fixes array mutation commands when using recursive descent paths (e.g. $..*) by applying mutations deepest-first (and for siblings, higher array indices first) so earlier updates don’t invalidate later matched paths.

This introduces shared path-comparison/sorting helpers and updates JSON.ARRPOP, JSON.ARRTRIM, and JSON.ARRINSERT to sort matched paths for safe in-place mutation while still returning results in the caller-expected order. New pytest coverage validates correct behavior on nested arrays for these commands.

Reviewed by Cursor Bugbot for commit 8f9251a. Bugbot is set up for automated code reviews on this repo. Configure here.

@AvivDavid23 AvivDavid23 requested a review from TalBarYakar April 9, 2026 10:24
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 95.94595% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.30%. Comparing base (e99a773) to head (8f9251a).

Files with missing lines Patch % Lines
redis_json/src/commands.rs 95.94% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1543      +/-   ##
==========================================
+ Coverage   75.18%   75.30%   +0.11%     
==========================================
  Files          15       15              
  Lines        4220     4240      +20     
==========================================
+ Hits         3173     3193      +20     
  Misses       1047     1047              

☔ 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