Skip to content

fix(commands): omit COUNT when count=None in the *MPOP commands - #4367

Merged
petyaslavova merged 5 commits into
redis:masterfrom
Rodrigo-Palma:bug-mpop-count-none
Oct 3, 2026
Merged

petyaslavova merged 5 commits into
redis:masterfrom
Rodrigo-Palma:bug-mpop-count-none

Conversation

@Rodrigo-Palma

@Rodrigo-Palma Rodrigo-Palma commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description of change

lmpop, blmpop, zmpop and bzmpop annotate count as int | None, but count=None appended COUNT None to the command:

r.zmpop(1, ["z"], min=True, count=None)
# execute_command('ZMPOP', 1, 'z', 'MIN', 'COUNT', None)
# DataError: A tuple item must be str, int, float or bytes.

The encoder rejects it before anything reaches the server. lpop, rpop and spop already treat count=None as "omit COUNT"; the four *MPOP commands now do the same, so the server applies its default of 1. Explicit counts go out as before.

The mixins are shared by the sync and async clients, so the one change covers both.

Test: test_mpop_commands_omit_count_when_none patches execute_command and checks the built args (no server needed). It fails on master for all four commands and passes with the fix; the existing *mpop tests still pass.

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

Note

Low Risk
Narrow command-encoding fix with parametrized tests; explicit count values behave as before.

Overview
Fixes a bug where passing count=None to lmpop, blmpop, zmpop, and bzmpop still appended COUNT with a None value to the Redis command, which the client encoder rejects before the request is sent.

blmpop and bzmpop now only add COUNT when count is not None. lmpop and zmpop keep omitting COUNT for the default of 1, and also skip it when count is None, matching behavior already used by commands like lpop / rpop.

Adds test_mpop_commands_omit_count_when_none, which asserts the four commands build the expected argument tuples without COUNT when count=None.

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

LMPOP, BLMPOP, ZMPOP and BZMPOP annotate count as `int | None`, but
passing None appended `COUNT None` to the command, which the encoder
rejects with DataError before anything reaches the server. LPOP, RPOP
and SPOP already treat count=None as "omit COUNT"; the four *MPOP
commands now do the same, and the server applies its default of 1.

@petyaslavova petyaslavova left a comment

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.

Hey @Rodrigo-Palma, thank you for your contribution! The change looks good, once we have a green CI, I will merge it.

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Oct 2, 2026
@petyaslavova
petyaslavova merged commit b6e371a into redis:master Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants