Fix SPOP with count returning nil instead of an empty set for a missing key - #2096
Merged
kevin-montrose merged 3 commits intoSep 11, 2026
Merged
Conversation
Copilot started reviewing on behalf of
Badrish Chandramouli (badrishc)
September 8, 2026 18:24
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The protocol-dependent RESP3 behavior and changed zero-count path need regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
kevin-montrose
approved these changes
Sep 11, 2026
x@01 (x-at-01)
added a commit
to webc-fork/garnet
that referenced
this pull request
Sep 12, 2026
…out-of-range (microsoft#2094), cluster READONLY/READWRITE (microsoft#2109)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SPOP has two reply shapes for a missing key in Redis: the no-count form replies nil, but the count form replies with an empty set (RESP2
*0, RESP3~0;spopWithCountCommandpassesshared.emptysettolookupKeyWriteOrReply).Garnet's SetPop handler replies nil for both forms. Any client that drains a set with
SPOP key <count>gets nil once the key disappears, where Redis hands back an empty collection. Typed clients that map the count form to a collection turn that into a null where application code expects an empty result.Change
SRANDMEMBER in the same file already makes exactly this distinction on its NOTFOUND branch; this change gives SPOP the same treatment, using the existing protocol-aware
WriteEmptySethelper so RESP3 gets the empty set type that the non-empty SPOP reply already uses. TheSPOP key 0early return is switched to the same helper (RESP2 output for it is unchanged).Added a test for the count-with-missing-key reply next to the existing no-count missing-key test, which keeps passing unchanged, showing the nil reply for the no-count form is untouched.
Verification
New test fails on main with
$-1\r\nwhere*0\r\nis expected, passes with the change. Full RespSetTest fixture: 86/86 pass (net10.0).