Skip to content

JSON.NUMINCRBY parsing broken for RESP2 - #3933

Merged
a-TODO-rov merged 4 commits into
redis:mainfrom
Dgramada:JSON-NUMINCRBY-broken-parsing-for-RESP2
Oct 6, 2026
Merged

a-TODO-rov merged 4 commits into
redis:mainfrom
Dgramada:JSON-NUMINCRBY-broken-parsing-for-RESP2

Conversation

@Dgramada

@Dgramada Dgramada commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On RESP2, JSON.NUMINCRBY with a JSONPath ($...) returned [0] instead of the new values, and null for non-numeric paths. RedisJSON sends RESP2 results as one bulk string of JSON text ([1928.5,2072.5]), which NumberListOutput tried to parse as a single number and fell back to 0. RESP3 was not affected.

Key Decisions & Assumptions

  • NumberListOutput now recognizes a bulk string of the form [...] and parses each element, turning null into null.
  • The array is split by hand instead of using JsonParser, because Jackson is optional and NUMINCRBY shouldn't require it. This relies on the reply always being a flat list of numbers and null.
  • NumberFormat is replaced by Long.parseLong with a Double.parseDouble fallback.

Behavioral / Conceptual Changes

  • RESP2 JSONPath results are now correct: [1928.5, 2072.5] instead of [0], and [null] instead of [0] for non-numeric paths.
  • Parsing no longer depends on the JVM default locale. With a German locale, 1929.5 used to parse as 19295.
  • On RESP2, a whole-number result of a float field (2.0) is now a Double instead of a Long, matching RESP3.

Testing

RedisJsonResp2IntegrationTests reruns the whole JSON integration suite on RESP2, and new tests cover multiple paths and a non-numeric path. Unit tests cover the RESP2 array forms, number types and locale independence. RedisJsonIntegrationTests now uses one client per class instead of one per test, which also stops leaking clients.


Note

Medium Risk
Changes shared command reply decoding for JSON.NUMINCRBY on RESP2; behavior is better covered by tests but relies on a simple comma-split for JSON array text rather than a full JSON parser.

Overview
Fixes RESP2 handling for JSON.NUMINCRBY when RedisJSON returns match results as a single bulk string of JSON text (e.g. [1928.5,2072.5] or [null]). NumberListOutput now treats [...] replies as a flat list of numbers/null instead of parsing the whole string as one number (which produced [0]).

Number parsing drops NumberFormat in favor of Long.parseLong / Double.parseDouble, so decimals are not mangled under non-English locales and numeric types stay closer to RESP3 (e.g. 2.0 as Double).

Tests add RedisJsonResp2IntegrationTests (full JSON suite on RESP2), integration cases for multi-path increment and non-numeric paths, and unit coverage for array forms and locale behavior. RedisJsonIntegrationTests uses one client per class via overridable getOptions().

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

Signed-off-by: yordantsintsov <yordan.tsintsov@gmail.com>
@Dgramada
Dgramada requested a review from a-TODO-rov October 1, 2026 16:08
@Dgramada Dgramada added the type: bug A general bug label Oct 1, 2026
@a-TODO-rov
a-TODO-rov merged commit 99ab863 into redis:main Oct 6, 2026
11 checks passed
@Dgramada
Dgramada deleted the JSON-NUMINCRBY-broken-parsing-for-RESP2 branch October 6, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址