Skip to content

MOD-21735: Keep comma-named siblings when collapsing nested paths - #1726

Open
AvivDavid23 wants to merge 1 commit into
masterfrom
MOD-21735-del-comma-named-sibling
Open

AvivDavid23 wants to merge 1 commit into
masterfrom
MOD-21735-del-comma-named-sibling

Conversation

@AvivDavid23

@AvivDavid23 AvivDavid23 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1711 (MOD-21735)

Problem

JSON.DEL with a recursive path left a member behind when its name contained a comma:

JSON.SET k $ '{"a":1,"a,b":2}'
JSON.DEL k '$..*'   ->  (integer) 1
JSON.GET k $        ->  [{"a,b":2}]

JSON.SET k '$..*' 0 had the same problem ("a,b" was not updated).

Fix

prepare_paths_for_updating removes paths nested under another selected path. It joined each path's segments with "," and checked string prefixes, so ["a,b"] looked like ["a"] + b and was dropped. It now compares segments directly: a path is dropped only if another selected path is a shorter segment prefix of it. The joined strings and their numeric sort, used only for that check, are removed.

This function is shared by JSON.DEL, JSON.SET and auto-create path updates.

Test plan

  • Rust unit test test_prepare_paths_for_updating_keeps_comma_named_siblings: ["a"] and ["a,b"] kept, ["a","b"] dropped (failed before fix)
  • Flow test testMutateCommaNamedSiblings: SET $..* updates both members; DEL $..* returns 2 and removes the key; real nesting still collapses (failed before fix)
  • cargo test -p redis_json 122/122; QUICK=1 suite 376/376; cargo clippy / cargo fmt --check clean
  • CI green

Note

Medium Risk
Changes shared path-deduplication logic for JSON mutation commands; behavior shift for keys with commas in member names, with targeted tests but broad call sites (DEL/SET/auto-create).

Overview
Fixes incorrect nested-path collapsing when object member names contain commas. prepare_paths_for_updating no longer joins segments into a string and tests prefix overlap; it marks a path for removal only when another selected path is a strictly shorter segment prefix (p.len() < path.len() && path.starts_with(p)).

Because this helper is shared by JSON.DEL, JSON.SET (via auto-create), and related multi-path mutations, recursive commands like $..* now update/delete both a and a,b instead of skipping the sibling whose name looks like a nested path. True nesting (e.g. a then b as separate segments) is still collapsed to the ancestor.

Adds a Rust unit test for comma-named siblings and a pytest flow covering JSON.SET/JSON.DEL with $..*.

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

prepare_paths_for_updating joined path segments with "," and detected
nesting by string prefix, so a member named "a,b" looked nested under
"a" and was dropped from JSON.DEL / JSON.SET updates. Compare segments
directly instead.
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.12%. Comparing base (d219b62) to head (4fa36e5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1726      +/-   ##
==========================================
- Coverage   88.13%   88.12%   -0.02%     
==========================================
  Files          18       18              
  Lines        6861     6852       -9     
==========================================
- Hits         6047     6038       -9     
  Misses        814      814              

☔ View full report in Codecov by Harness.
📢 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.

@TalBarYakar TalBarYakar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scans all paths for each match, which gets expensive on large objects. In a local benchmark with 60k children, filtering went from ~3 ms to ~810 ms

This branch has not been deployed

No deployments
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.

[Bug]: JSON.DEL leaves a comma-named sibling after wildcard deletion

2 participants