Repository navigation
MOD-16872 make apply_updates return the current status of updates - #1621
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1621 +/- ##
==========================================
+ Coverage 85.86% 85.93% +0.07%
==========================================
Files 15 15
Lines 5241 5275 +34
==========================================
+ Hits 4500 4533 +33
- Misses 741 742 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
apply_updates return True if at least one update w…apply_updates return the current status of updates
| redis_key.notify_keyspace_event(ctx, "json.set")?; | ||
| manager.apply_changes(ctx); | ||
| } | ||
| if result.all_updated() { |
There was a problem hiding this comment.
write some comments to explain the return value paths
There was a problem hiding this comment.
Its literarily what the code says.. If all updates were to all paths Ok, return Ok, else RedisValue::Null
There was a problem hiding this comment.
I prefer having a comment at the function header so its purpose is clear without needing to jump into the implementation.
| if any_updated { | ||
| redis_key.notify_keyspace_event(ctx, "json.mset")?; | ||
| } | ||
| all_updated &= key_all_updated; |
There was a problem hiding this comment.
Why do we need the all_updated logic ?
if you fail to do something , isn't it good enough to just return a mid loop error and thats it ?
if we finish all the loop we can retun 'REDIS_OK'
There was a problem hiding this comment.
This would be a breaking change.. though I agree with you
There was a problem hiding this comment.
@gabsow for context, let say we have:
JSON.MSET a $ '{"a":"b"}' b $ wada c $ '{"a":"b"}'
currently, setting a will work, b will fail but we will continue to c,
Tal is suggesting stop after b fail
(in practice, in this example. nothing will run because we validate the input first, including the json given but lets assume we are not for this example)
| all_updated &= key_all_updated; | ||
| } | ||
|
|
||
| manager.apply_changes(ctx); |
There was a problem hiding this comment.
Correctness — partial writes may not be replicated on a mid-loop error. The loop now uses ? directly (open_key_write/from_str on 721-723, and the root-path set_value? on 734), so any error early-returns from the whole command. But by then earlier keys in parsed may already have been mutated in place and had notify_keyspace_event fired, while manager.apply_changes(ctx) (replicate_verbatim) is only reached after the loop. An error on key N>1 therefore leaves the master mutated but the replica/AOF never receives those writes → divergence. The old fold always ran apply_changes afterwards, so this is a regression. Validating/opening all keys up front (so the apply loop is infallible) — or running apply_changes before propagating the error — would close the gap.
|
|
||
| manager.apply_changes(ctx); | ||
| res | ||
| if all_updated { |
There was a problem hiding this comment.
Semantics — a nil reply here no longer means "nothing changed." Re: the all_updated discussion above — worth deciding two consequences deliberately, since the tests assert that MSET (and SET, see line 453) can return nil while having already mutated and replicated a subset of keys:
nilhas historically meant "no write happened" (e.g. NX/XX miss). Overloading it to also mean "partial write happened" is ambiguous for clients.- A client that retries on
nilre-applies the keys that already succeeded — not idempotent for append/merge-style paths.
If the intent is all-or-nothing, the failing command's writes shouldn't be committed/replicated at all; if it's "best-effort + report," an error (rather than nil) would disambiguate success-with-partial-failure from a plain miss. Either way it's a client-visible contract change worth documenting.
| redis_key.notify_keyspace_event(ctx, "json.set")?; | ||
| manager.apply_changes(ctx); | ||
| } | ||
| if result.all_updated() { |
There was a problem hiding this comment.
Behavior change — this narrows JSON.SET's reply too, not only JSON.MSET. The active thread is on the MSET side, but the same all_updated change applies here to JSON.SET with a multi-match path (e.g. $..x): previously it replied OK if at least one match was written; now it replies nil unless every matched path succeeds (while still writing + replicating the ones that did — see testApplyUpdatesFoldDoesNotLoseEarlierSuccess). That's a contract change for a very common command, and it isn't reflected in the PR title/description (scoped to apply_updates/MSET). Please confirm it's intended and document it.
| export CC=/usr/bin/clang CXX=/usr/bin/clang++ | ||
| fi | ||
| make test 2>&1 | tee test_output.log | ||
| PARALLEL=1 make test 2>&1 | tee test_output.log |
There was a problem hiding this comment.
CI risk — this runs the entire suite in parallel on macOS. Together with dropping [[ $OS == macos ]] && PARALLEL=0 in tests.sh, this forces PARALLEL=1 on macOS. That guard's comment documented a real failure ("Can't pickle local object" in RLTest), and it was global — so any test in the suite that defines a local/nested function or lambda (not just the ones added here) can now break macOS CI under multiprocessing. If the underlying pickling issue is fixed, great; otherwise this re-introduces the flake the guard prevented. Worth confirming a full macOS run is green before merge.
| env.expect("JSON.SET", "c{s}", '$', '{"x": 1}').ok() | ||
|
|
||
| with env.getClusterConnectionIfNeeded() as r: | ||
| r.execute_command('config', 'set', 'notify-keyspace-events', 'KEA') |
There was a problem hiding this comment.
Test hygiene — notify-keyspace-events is set on the shared env and never restored. test_mset_replication_in_aof does the same config set … KEA but on an isolated Env(useAof=True); this test mutates the shared server's config (and leaves the pubsub subscribed) without resetting it, so later tests in the module run with keyspace notifications forced on. Consider restoring the previous value and closing/unsubscribing the pubsub in a finally, or using an isolated Env.
|
|
||
| # A value nested 60 arrays deep (calculate_value_depth() == 60). | ||
| patch_nesting = 60 | ||
| patch = ('[' * patch_nesting) + '0' + (']' * patch_nesting) |
There was a problem hiding this comment.
Test brittleness — depth arithmetic is pinned to internal limit constants. The 60/102/128 math (shallow 2+60=62 < 128 succeeds, deep 102+60=162 ≥ 128 fails) hard-codes the current recursion limit and depth counting. If either changes, both $..x matches will both succeed or both fail — the test then fails at the first assertEqual(res, None) or at the $.a.x GET rather than clearly signaling "the limit moved." Deriving the patch depth from the limit constant (or a comment naming it) would make the failure mode legible.
Co-authored-by: Tom Gabsow <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ec4a0ef. Configure here.
| msg = pubsub.get_message(timeout=1) | ||
| env.assertEqual(msg['type'], 'pmessage') | ||
| env.assertEqual(msg['data'], key) | ||
| env.assertEqual(pubsub.get_message(timeout=1), None) |
There was a problem hiding this comment.
Shared env keyspace config leak
Medium Severity
testMSET_FailsOverallIfAnyKeyFailed sets notify-keyspace-events to KEA on the shared suite env and leaves a pubsub psubscribe active without restoring the prior config or cleaning up the subscription. Later tests on the same server can see unexpected keyspace traffic or run with notifications forced on.
Reviewed by Cursor Bugbot for commit ec4a0ef. Configure here.
|
|
||
| PARALLEL=${PARALLEL:-1} | ||
|
|
||
| # due to Python "Can't pickle local object" problem in RLTest |
There was a problem hiding this comment.
macOS CI forced parallel tests
Medium Severity
This commit removes the macOS-only PARALLEL=0 guard in tests.sh and sets PARALLEL=1 in the macOS workflow. That re-enables RLTest multiprocessing on macOS despite the prior documented pickling failure, so unrelated tests can break CI even if the new MSET cases pass.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ec4a0ef. Configure here.
* MOD-13014: redact user data from JSONPath trace logs (#1605) MOD-13014 removed user data from errors but left the JSONPath engine's trace logs, which still emitted document values, query literals and paths at Redis `debug` log level (trace! maps to RedisLogLevel::Debug). Gate those traces behind a cached mirror of Redis core's `hide-user-data-from-log` server config: a new `trace_user_data!` macro suppresses the message when the flag is on. The module reads the config at load and refreshes it on CONFIG SET via a config-changed event handler. Structural traces (grammar rules, "missing operand" diagnostics) stay on plain trace! and are unaffected. Co-authored-by: Claude Opus 4.8 <[email protected]> * remove `#[cfg(not(feature = "as-library"))]` from `sync_hide_user_dat… (#1613) * MOD-16366 json add flow tests to check llapi c api (#1614) * MOD-16366 LLAPI flow tests * remove `#[cfg(not(feature = "as-library"))]` from `sync_hide_user_data_from_log` * remove `#[cfg(not(feature = "as-library"))]` from `sync_hide_user_data_from_log` * fail if module not available * fixes * CR * . * CR * MOD-16514 - fix bootstrap & build for al os (#1612) * alma8 +rhel8+rhel9+bionic +focal passes * fix for alpine * fix for bionic * fix * fix mariner * fix bionic bootstrap * fix bionic * fix bionic * fi bionic * fix bionic * install aws cli for json * bionic fix * fix bionic * fix for focal * fix for focak * fix for bionic & focal &mariner&alpine * apply fixes * fix remarks * fix for alpine * try another methood * ci: source $HOME/.cargo/env in flow-clippy so cargo is on PATH Match flow-linter.yml; getrust.sh now installs Rust user-scoped, so later Actions steps don't see cargo without sourcing the env. * CI was failing because getrust.sh ran twice. install_script.sh already invokes it from the repo root (works), but the workflow then called ./getrust.sh sudo again from working-directory: .install — where rust-toolchain.toml doesn't exist, so its `sed rust-toolchain.toml` errored with "No such file or directory" (exit 2). Removed the redundant ./getrust.sh line from flow-linter.yml and flow-clippy.yml; install_script.sh handles Rust install on its own. * ci(macos): add rust-toolchain.toml to sparse checkout The macOS "Deps checkout" fetches only .install and test requirements, then runs install_script.sh -> getrust.sh, which reads rust-toolchain.toml from the repo root to resolve the pinned toolchain. That file wasn't in the sparse list, so getrust failed with "sed: rust-toolchain.toml: No such file or directory". Add it to the sparse-checkout. * MOD-16300 perf(json_path): materialize filter literals once per query (#1615) * MOD-16300 perf(json_path): materialize filter literals once per query * simplify * CR + Reuse cache in whole query * MOD-16608 Bump ijson(reduce object memory) (#1617) * MOD-16608 Bump ijson(reduce object memory) * clippy * fix memory test * MOD-16274 | MOD-16275 add size/sizeof and empty operators on object (#1618) * MOD-16685 Add RedisJSON API to open from RedisModuleKey (#1619) * MOD-16685 Add RedisJSON API to open from RedisModuleKey Add a RedisJSON shared API V8 entry that opens a JSON root from an already-open RedisModuleKey handle. This lets consumers such as RediSearch reuse an existing key handle instead of manually checking isJSON and calling RedisModule_ModuleTypeGetValue. Update the RediSearch RedisJSON API header copy and add LLAPI coverage for the new openKeyFromHandle path. * use Imanager to get value for json * fix clippy * rename functions * fix compilation * MOD-16872 make `apply_updates` return the current status of updates (#1621) * add docker image managment to json (#1622) * Add `AGENTS.md` and `CLAUDE.md` * ignore AGENS.MD in spellcheck * ignore CLAUDE.MD in spellcheck * [MOD-17021] Add getWithPath LLAPI to evaluate a pre-compiled JSONPath (#1623) * MOD-16899: add getWithPath LLAPI to evaluate a pre-compiled JSONPath Adds a V9 RedisJSON C API entry getWithPath(json, JSONPath) that evaluates an already-compiled path (from pathParse) instead of a path string, skipping the per-call pest compilation. Callers that resolve the same path across many documents (e.g. RediSearch FT.AGGREGATE LOAD) can compile once and reuse the handle. - c_api.rs: json_api_get_with_path + exported JSONAPI_getWithPath, struct/initializer entry, REDIS_JSONAPI_LATEST_API_VER 8->9; parity unit test (getWithPath == get). - include/rejson_api.h: getWithPath declaration + LATEST_API_VER bump. lib.rs: register the entrypoint. Co-Authored-By: Claude Opus 4.8 <[email protected]> * MOD-16899: add LLAPI flow test for getWithPath Extend the llapi_test_module consumer with LLAPI.OPEN_GET_WITH_PATH (pathParse + getWithPath, via an open_and_get_with_path helper mirroring open_and_get, sharing reply_nodes_as_json with OPEN_GET) and assert in test_llapi.py that it matches LLAPI.OPEN_GET, plus missing-key / bad-path / projection error cases. Co-Authored-By: Claude Opus 4.8 <[email protected]> * getWithPath: reject projections at runtime like json_api_get Replace the debug_assert with 'if query.is_projection() { return null(); }' so a projection path is handled identically to the string-based json_api_get in all builds (not just debug), and defensively at the FFI boundary. Add a unit test passing a compiled projection Query directly. Co-Authored-By: Claude Opus 4.8 <[email protected]> * getWithPath: trim projection comments Drop the self-explanatory test doc comment and shorten the guard comment to a one-liner referencing json_api_get. Co-Authored-By: Claude Opus 4.8 <[email protected]> * getWithPath: drop json_api_get reference from projection guard comment Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]> * MOD-16952 - enhance bootstrap (add list and dry-run arg) (#1624) * enhance bootstrap - add check-deps * write list to afile * add optional deps * add another optional deps * add another optional deps * add versioning managment * rename command to list * renme to list * add dry run * fix colors * fix missing uv * remove min cmake version * fix remarks * add the retry mechanizm to json as well * fix remarks * fix remarks * add _sh so we can have the full bootstrap output * always return to the workspace dir * make single copy paste install all * fix alma8 * fix bad dry-run print * gaurd tool-set version 11 * fix curl minimal * remove centos-release-scl for amazonlinux2 * fix macos env * fix(bootstrap): make sudo a no-op on root containers without a sudo binary The install scripts run privileged steps via literal `sudo` inside `_sh` command strings (e.g. `sudo ln -sf ...`, `| sudo tee`, `&& sudo make install`). On a slim Docker image that runs install_script.sh directly as root with no `sudo` package installed (e.g. RedisTimeSeries' amazonlinux2 CI), those steps fail with `sudo: command not found` (exit 127), aborting the whole bootstrap. Add a root-only pass-through in pm.sh/deps_lib.sh: when running as root and no real `sudo` binary exists, define `sudo()` to run its arguments directly. When not root, a missing sudo stays a genuine error and is left unmasked. * version update * Revert "[MOD-17021] Add getWithPath LLAPI to evaluate a pre-compiled JSONPath (#1623)" This reverts commit 628013e. --------- Co-authored-by: Tom Gabsow <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: Aviv David <[email protected]> Co-authored-by: avivdavid23 <[email protected]> Co-authored-by: Itzikvaknin <[email protected]>
## Module Update This PR bumps the pinned **MODULE_VERSION** for **RedisJSON** from **v8.9.90** to **v8.10.0**. RedisBloom and RedisTimeSeries are unchanged. ## Changes | Module | From | To | | -- | -- | -- | | RedisJSON | v8.9.90 | v8.10.0 | **Note:** this RedisJSON range contains 6 relevant commits. The main changes are apply_updates status reporting, Docker image management, bootstrap list / dry-run support, and agent guidance / spellcheck updates. ## Module Changes [RedisJSON range](RedisJSON/RedisJSON@v8.9.90...v8.10.0) - MOD-16872 — make `apply_updates` return the current update status instead of only applying changes, with pytest and CI updates ([#1621](RedisJSON/RedisJSON#1621)) - No ticket — add Docker image management for RedisJSON CI/release flows, including Docker image push workflow wiring ([#1622](RedisJSON/RedisJSON#1622)) - No ticket — add `AGENTS.md` and `CLAUDE.md` repo guidance files - No ticket — ignore `AGENTS.md` in spellcheck - No ticket — ignore `CLAUDE.md` in spellcheck - MOD-16952 — enhance bootstrap with dependency listing, dry-run support, retry handling, optional dependency handling, and root-without-sudo support for slim containers ([#1624](RedisJSON/RedisJSON#1624)) ## Excluded Commits **1 commit excluded** MOD-17021 / [#1623](RedisJSON/RedisJSON#1623) is intentionally excluded from this description. ## Verification - [ ] CI passes for RedisJSON at the new pinned version - [ ] `make all` builds RedisJSON cleanly against unstable - [ ] Module tests run under `make test` --- *This PR was automatically created by the Redis Module Release Orchestrator.* <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Single manifest pin bump with no Redis core or load-path changes; risk is limited to RedisJSON module behavior at the new upstream release. > > **Overview** > Pins **RedisJSON** in `modules/modules.yaml` from **v8.9.90** to **v8.10.0**; RedisBloom, RediSearch, and RedisTimeSeries refs are unchanged. > > After merge, `make modules-update redisjson` (or a full modules refresh) will pull the new tag for `modules/redisjson/src/` and rebuild **`rejson.so`** per the existing manifest wiring. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 27f5ca7. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->


…as succeeded
This fixes issue when multiple paths are being updated. Previously, if one of the updates failed, the command will not be replicated to slaves. User will still get the original None response if one of the updates failed. Changing the same response for MSET
Note
Medium Risk
Changes write-command success, notification, and replication semantics for JSON.SET/MSET on partial failures; behavior is well covered by new tests but clients relying on old OK-on-partial-write behavior may see different replies.
Overview
JSON.SET and JSON.MSET now distinguish whether any matched path/key was written from whether every update succeeded.
apply_updatesreturns anApplyUpdatesResult(NoneUpdated/SomeUpdated/AllUpdated) and aggregates multi-path results withcombineinstead of folding booleans with||, so a later success is not treated as full success after an earlier failure.When only some paths or keys apply, the reply stays nil (not OK), but keys that did change still get keyspace notifications and
apply_changesso replication matches applied data. JSON.MSET tracks per-key success and only returns OK when every triplet fully succeeds.Pytests cover partial MSET, keyspace events, a deep JSON.SET multi-match case, and depth-limit MSET overall failure. Linux/macOS CI and
tests.shenable parallel RLTest (PARALLEL=1), including removing the macOS-only serial override.Reviewed by Cursor Bugbot for commit ec4a0ef. Bugbot is set up for automated code reviews on this repo. Configure here.