Fix FIELDS argument validation in HSETEX/HGETEX#14883
Conversation
🤖 Augment PR SummarySummary: This PR makes 🤖 Was this summary useful? React with 👍 or 👎 |
| addReplyError(c, "wrong number of arguments"); | ||
| return C_ERR; | ||
| } | ||
|
|
There was a problem hiding this comment.
let's also make sure that the FIELDS arg was even given (in parseHashCommandArgs and parseHashFieldExpireArgs)
There was a problem hiding this comment.
I don't get it well.
Do you refer to FIELDS itself or its following arguments numfields field value [field value ...]?
There was a problem hiding this comment.
I guess you refer to the FIELDS itself. However I wonder it's necessity, because command has arity like 6 for HSETEX, execute command without enough arity would raise the error as below:
127.0.0.1:6379> hsetex myhash FNX EX 100
(error) ERR wrong number of arguments for 'hsetex' command
and we do not allow FNX + FXX, or EX 100 + KEEPTTL at same time, that would raise another error:
127.0.0.1:6379> hsetex myhash FNX EX 100 KEEPTTL
(error) ERR Only one of EX, PX, EXAT, PXAT or KEEPTTL arguments can be specified
another specific case is, FIELDS is not specified, it would raise an error like:
127.0.0.1:6379> hsetex myhash FNX EX 100 1 k v
(error) ERR unknown argument: 1
There was a problem hiding this comment.
Hi @guybe7 I might understand your point, could you review the latest changes?
|
@gentcys pls update the top comment, I see the change of needing at least one field was missed. |
|
@sundb Is the updated title and top comment good by now? |
Fixes redis#14879 Improve validation of the FIELDS argument in HSETEX and HGETEX to ensure exactly one field is provided, rejecting both missing and multiple fields with consistent and accurate error messages. Align behavior across both commands.
Fixes #14879 Improve validation of the FIELDS argument in HSETEX and HGETEX to ensure exactly one field is provided, rejecting both missing and multiple fields with consistent and accurate error messages. Align behavior across both commands.

Fixes #14879
Improve validation of the FIELDS argument in HSETEX and HGETEX to ensure exactly one field is provided, rejecting both missing and multiple fields with consistent and accurate error messages.
Align behavior across both commands.
Note
Medium Risk
Tightens argument validation for
HSETEX/HGETEXand the HEXPIRE-family parsers, which can change previously-accepted (but ambiguous) command forms into hard errors and may impact client compatibility.Overview
Prevents ambiguous hash field-expiration invocations by enforcing that
FIELDSis present exactly once.parseHashFieldExpireArgs()now errors ifFIELDSis specified multiple times and rejects calls that omitFIELDSentirely; the flexibleparseHashCommandArgs()used by the HEXPIRE family similarly rejects missingFIELDS. Unit tests add coverage thatHSETEXwith repeatedFIELDSreturns an error.Written by Cursor Bugbot for commit 470e676. This will update automatically on new commits. Configure here.