Skip to content

fix(bitmap): pad BITOP operands and treat missing keys as empty - #593

Merged
cunla merged 1 commit into
cunla:masterfrom
kratos0718:bitop-pad-missing
Sep 30, 2026
Merged

cunla merged 1 commit into
cunla:masterfrom
kratos0718:bitop-pad-missing

Conversation

@kratos0718

Copy link
Copy Markdown
Contributor

BITOP combined the operands with zip(), so the result was cut to the shortest operand, and a missing first key raised a Python TypeError. With key1 = "hello" and key2 = "10", compared with a real Redis 8.10:

command redis fakeredis
BITOP OR dest key1 key2 5, yullo 2, yu
BITOP AND dest key1 missing 5, five zero bytes 0, empty string
BITOP OR dest missing key1 5, hello TypeError
BITOP AND dest missing missing2 0, dest deleted TypeError
BITOP NOT dest missing 0, dest deleted TypeError

Operands are now padded with zero bytes to the longest one, missing keys count as empty strings, and an empty result deletes the destination instead of storing "". The existing test only used operands of the same length. The new test passes against the real server (Strict2/Strict3) and fails on master for FakeStrict2/FakeStrict3.

BITOP combined the operands with zip(), so the result was cut to the
shortest string, and a missing first key raised a TypeError. Redis pads
every operand with zero bytes to the longest one, treats missing keys as
empty strings, and deletes the destination when the result is empty.
@kratos0718
kratos0718 requested a review from cunla as a code owner September 29, 2026 17:04
@cunla
cunla merged commit 6cfb252 into cunla:master Sep 30, 2026
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.

2 participants