Skip to content

Add FPHA (floating-point homogeneous array) arg support to JSON.SET#4011

Open
petyaslavova wants to merge 5 commits intomasterfrom
ps_add_json_set_fpha_arg
Open

Add FPHA (floating-point homogeneous array) arg support to JSON.SET#4011
petyaslavova wants to merge 5 commits intomasterfrom
ps_add_json_set_fpha_arg

Conversation

@petyaslavova
Copy link
Copy Markdown
Collaborator

@petyaslavova petyaslavova commented Mar 30, 2026

Add FPHA (floating-point homogeneous array) support to JSON.SET

This PR adds support for the FPHA (Floating-Point Homogeneous Array) argument in JSON.SET, available in Redis 8.8+. The new fpha parameter allows users to specify a floating-point storage type (BF16, FP16, FP32, or FP64) for numeric arrays, enabling memory optimization by forcing Redis to store all floating-point values in an array using a specific precision.
The parameter is added to set(), set_file(), and set_path() methods, with full sync/async parity including all @overload signatures and the AsyncJSON class overrides.

A new FPHAType(str, Enum) is introduced and exported from redis.commands.json for convenient, type-safe usage (e.g., fpha=FPHAType.FP32). Plain strings are also accepted and validated client-side — invalid values raise a DataError before reaching the server. Case-insensitive string input is supported (e.g., "fp32" is normalized to "FP32").

Tests cover all FPHA types, enum usage, case-insensitive input, combination with NX/XX modifiers, and client-side validation of invalid types. Server-dependent tests are gated behind @skip_if_server_version_lt("8.7.0"), while client-side validation tests run unconditionally.


Note

Medium Risk
Extends the JSON.SET command builder and related helpers (set_file/set_path) with a new argument, which could affect request serialization and error handling for JSON writes. Risk is limited by client-side validation and targeted tests but still touches a core command path.

Overview
Adds support for the RedisJSON JSON.SET FPHA modifier via a new fpha parameter (accepting FPHAType enum or case-insensitive strings) on set(), set_file(), and set_path() across sync and asyncio clients.

Introduces FPHAType with client-side validation (invalid values raise DataError) and wires FPHA <type> into the constructed JSON.SET argument list when provided. Updates tests (sync + asyncio) to cover valid FPHA types, enum usage, case-insensitivity, NX/XX interaction, and invalid-type validation, with server-version-gated cases using skip_if_server_version_lt.

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

@petyaslavova petyaslavova added the feature New feature label Mar 30, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci bot commented Mar 30, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

pieces.extend(["FPHA", fpha.value])
else:
try:
fpha_enum = FPHAType(fpha.upper())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it does makes sense to move this data validation into a FPHAType object itself

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

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

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants