Repository navigation
[Objects] Do not create an empty object for LSET, HDEL and HPERSIST on a missing key - #2192
Merged
Badrish Chandramouli (badrishc) merged 3 commits intoOct 2, 2026
Conversation
Copilot started reviewing on behalf of
Federico Laurianti (Laurianti)
September 30, 2026 20:16
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation matches the title, description, command handlers, and regression coverage with no identified issues.
Review effort: Balanced
Findings: None
What changed in this PR
Prevents LSET, HDEL, and HPERSIST from creating empty objects when their keys are missing, aligning behavior with Redis and partially addressing #2191.
Changes:
- Marks the three operations as non-creating.
- Adds regression tests for missing-key responses and key existence.
- Leaves
ZADD XXexplicitly out of scope.
| File | Description |
|---|---|
libs/server/Objects/Types/GarnetObject.cs |
Disables initial object creation for the affected operations. |
test/standalone/Garnet.test.collections/RespListTests.cs |
Tests missing-key LSET behavior. |
test/standalone/Garnet.test.collections/RespHashTests.cs |
Tests missing-key HDEL and HPERSIST behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Badrish Chandramouli (badrishc)
approved these changes
Oct 1, 2026
Federico Laurianti (Laurianti)
force-pushed
the
fix-no-create-on-missing-key
branch
from
October 1, 2026 01:32
e2f0ebb to
63b9cf5
Compare
Federico Laurianti (Laurianti)
force-pushed
the
fix-no-create-on-missing-key
branch
from
October 1, 2026 01:36
63b9cf5 to
e2f0ebb
Compare
Contributor
Author
Badrish Chandramouli (badrishc)
merged commit Oct 2, 2026
99739d2
into
microsoft:main
5 checks passed
x@01 (x-at-01)
added a commit
to webc-fork/garnet
that referenced
this pull request
Oct 4, 2026
…n missing key (microsoft#2192), ZADD XX INCR null (microsoft#2197), no empty object from object RMW (microsoft#2194), fresh ObjectOutput per key HCOLLECT/ZCOLLECT (microsoft#2200), CompletionEvent disposal + LogSizeTracker coalesce (microsoft#2198), dynamic test ports (microsoft#2193)
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.
Root Cause
GarnetObject.NeedToCreatedecides whether an object RMW on a missing key creates the object.LSET,HDELandHPERSISTwere missing from the list of operations that must not create it, so on a missing key they created an empty list or hash. The key then showed up inEXISTS,TYPEandDBSIZE,LPUSHX/RPUSHXpushed into it, andLINSERTgot no reply.Description of Change
libs/server/Objects/Types/GarnetObject.cs:ListOperation.LSET,HashOperation.HDELandHashOperation.HPERSISTadded to the operations that do not create the object. Their handlers already reply onNOTFOUND(ERR no such key,0, and an array of-2).ZADDwithXXhas the same problem but is not changed here:XXis an option ofZADD, so it needs the options from the input and aNOTFOUNDreply in the handler.Tests
RespListTests.LSETOnMissingKeyDoesNotCreateKey: afterLSETon a missing key, the key does not exist andLPUSHX,RPUSHXandLINSERTreturn 0.RespHashTests.HDELAndHPERSISTOnMissingKeyDoNotCreateKey: afterHDELandHPERSISTon a missing key, the key does not exist.Garnet.test.collections: 782 passed, net10.0 Release.Issues Fixed
Part of #2191: fixes
LSET,HDELandHPERSIST;ZADD XXremains open.