Skip to content

Fix IFDEQ/IFDNE digest argument type in SET and DELEX command json file#15305

Merged
sundb merged 1 commit into
redis:unstablefrom
daguimu:fix/ifdeq-ifdne-digest-arg-type
Jun 17, 2026
Merged

Fix IFDEQ/IFDNE digest argument type in SET and DELEX command json file#15305
sundb merged 1 commit into
redis:unstablefrom
daguimu:fix/ifdeq-ifdne-digest-arg-type

Conversation

@daguimu

@daguimu daguimu commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

The IFDEQ/IFDNE match-digest argument of SET and DELEX is declared as integer in the command metadata, but it is actually a hexadecimal string. This makes COMMAND DOCS/COMMAND INFO report a wrong argument type to clients and tooling (e.g. client libraries that generate bindings or validate arguments from command metadata).

What changed

  • src/commands/set.json, src/commands/delex.json: change ifdeq-digest/ifdne-digest type from integer to string.
  • src/commands.def: regenerated from the JSON via utils/generate-command-code.py.
  • tests/unit/introspection-2.tcl: add a test asserting COMMAND DOCS reports the IFDEQ/IFDNE digest arguments as string for both SET and DELEX.

Why this is correct

The digest argument is a fixed-length hex string, not an integer:

  • It is validated by validateHexDigest() in src/t_string.c, which requires exactly DIGEST_HEX_LENGTH (16) hexadecimal characters.
  • It is compared with strcasecmp() (string comparison) in setGenericCommand() (src/t_string.c) and delexCommand() (src/db.c).
  • DIGEST/stringDigest() produce the value with a PRIx64 hex format, so a typical digest such as f7042be43fb80714 is not a valid integer.

The sibling IFEQ/IFNE match-value arguments are already correctly typed as string.

Test plan

  • New test SET/DELEX IFDEQ/IFDNE digest arguments are typed as string passes.
  • Mutation-verified: reverting the type back to integer makes the new test fail, confirming it exercises the change.
  • unit/introspection-2 suite passes.

Note

Low Risk
Documentation and generated introspection tables only; no runtime command logic changes.

Overview
Corrects command introspection metadata for SET and DELEX so IFDEQ / IFDNE digest operands are documented as string, not integer.

Updates src/commands/set.json and src/commands/delex.json, with matching regeneration in src/commands.def. COMMAND DOCS / COMMAND INFO (and tooling that consumes them) will now report hex digest arguments consistently with IFEQ / IFNE value args and with runtime handling (hex string validation/comparison). No change to command parsing or server behavior—only the published argument types.

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

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 this test is an overkill and should be removed. @sundb WDYT?

As a side note, maybe it's a good idea to have some sort of tests to avoid these kinds of mistakes, but they have to be generic (written once, and not for each new param/cmd) and also this is outside the scope of this PR.

@sundb sundb Jun 5, 2026

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 this test is an overkill and should be removed. @sundb WDYT?

agree with you.

As a side note, maybe it's a good idea to have some sort of tests to avoid these kinds of mistakes, but they have to be generic (written once, and not for each new param/cmd) and also this is outside the scope of this PR.

Maybe we can verify it in req-res-log-validator.py

The IFDEQ/IFDNE match-digest argument of SET and DELEX was declared as
"integer" in the command JSON, but it is actually a hexadecimal string:
the implementation validates it with validateHexDigest() (requiring
exactly DIGEST_HEX_LENGTH hex characters) and compares it with
strcasecmp(), and DIGEST/stringDigest() produce the value via a PRIx64
hex format. The sibling IFEQ/IFNE match-value arguments are already
correctly typed as "string".

Change the type to "string" in set.json and delex.json and regenerate
commands.def.
@daguimu daguimu force-pushed the fix/ifdeq-ifdne-digest-arg-type branch from 6493de6 to 3354a44 Compare June 7, 2026 13:19
@daguimu

daguimu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @minchopaskal @sundb — removed the test. The PR is now just the metadata type fix (integer -> string). Agree a generic check is the better long-term approach and out of scope here.

@sundb sundb changed the title Fix IFDEQ/IFDNE digest argument type in SET and DELEX command docs Fix IFDEQ/IFDNE digest argument type in SET and DELEX command json file Jun 17, 2026
@sundb sundb merged commit 4885bca into redis:unstable Jun 17, 2026
18 of 19 checks passed
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.

3 participants