microsoft/garnet · error · GarnetException
RI.SET: invalid arguments.
Error message
RI.SET: invalid arguments.
What it means
RI.SET (RangeIndex SET) throws when the underlying BfTree (Bloom-filter tree) insertion returns InvalidArguments. This indicates the field or value passed to the native tree was structurally invalid at the lowest level — typically a null or empty span, or a corrupted tree handle. It is distinct from InvalidKV which is a size-constraint error returned as a normal RESP error.
Source
Thrown at libs/server/Storage/Session/MainStore/RangeIndexOps.cs:228
{
result = RangeIndexResult.Error;
errorMsg = "ERR no such range index"u8;
return GarnetStatus.OK;
}
var treePtr = ExtractTreePtr(stubSpan);
if (treePtr == 0)
{
result = RangeIndexResult.Error;
errorMsg = "ERR no such range index"u8;
return GarnetStatus.OK;
}
var insertResult = BfTreeService.InsertByPtr(treePtr, field, value);
if (insertResult == BfTreeInsertResult.InvalidArguments)
{
logger?.LogError("RI.SET: invalid arguments for a {keyLen}-byte field and {valueLen}-byte value.", field.Length, value.Length);
throw new GarnetException("RI.SET: invalid arguments.");
}
if (insertResult == BfTreeInsertResult.InvalidKV)
{
ref readonly var stub = ref RangeIndexManager.ReadIndex(stubSpan);
result = RangeIndexResult.Error;
errorMsg = System.Text.Encoding.UTF8.GetBytes(
$"ERR key+value size must be between {stub.MinRecordSize} and {stub.MaxRecordSize} bytes (got {field.Length + value.Length}), max key length {stub.MaxKeyLen} (got {field.Length})");
return GarnetStatus.OK;
}
result = RangeIndexResult.OK;
functionsState.rangeIndexManager.ReplicateRangeIndexSet(
key, field, value, functionsState.appendOnlyFile,
stringBasicContext.Session.Version, stringBasicContext.Session.ID,
functionsState.StoredProcMode);
View on GitHub (pinned to 951b0fc683)
Solutions
- Ensure the field and value arguments to RI.SET are non-empty and within the tree's MinRecordSize..MaxRecordSize range.
- If the error persists with valid arguments, the range index tree may be corrupted — recreate the range index.
- Check the server logs for the logged field/value byte lengths to confirm the inputs that triggered the error.
Example fix
// before RI.SET myindex "" "value" // after RI.SET myindex "field1" "value"
Defensive patterns
Strategy: validation
Validate before calling
if (field == null || field.Length == 0)
throw new ArgumentException("RI.SET field must be non-empty.");
if (value == null || value.Length == 0)
throw new ArgumentException("RI.SET value must be non-empty."); Prevention
- Validate field and value are non-empty before calling RI.SET.
- Check the range index stub exists (treePtr != 0) before insertion.
- Log field/value lengths alongside the error for debugging.
When it happens
Trigger: Calling the RI.SET operation path in RangeIndexOps when BfTreeService.InsertByPtr returns BfTreeInsertResult.InvalidArguments. Occurs when the field span or value span is empty/null, or the tree pointer resolves to a corrupted internal state.
Common situations: Client sending RI.SET with an empty field or value; a bug in argument parsing that passes a zero-length span; corrupted range index state after an unclean shutdown.
Related errors
- RI.GET: invalid arguments.
- RI.DEL: invalid arguments.
- ERR bit offset is not an integer or out of range
- Object store is disabled
- invalid failover status
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/21f790ad598478ec.
Report an issue: GitHub.