{"record":{"id":"21f790ad598478ec","repo":"microsoft/garnet","slug":"ri-set-invalid-arguments","errorCode":null,"errorMessage":"RI.SET: invalid arguments.","messagePattern":"RI\\.SET: invalid arguments\\.","errorType":"exception","errorClass":"GarnetException","httpStatus":null,"severity":"error","filePath":"libs/server/Storage/Session/MainStore/RangeIndexOps.cs","lineNumber":228,"sourceCode":"                {\n                    result = RangeIndexResult.Error;\n                    errorMsg = \"ERR no such range index\"u8;\n                    return GarnetStatus.OK;\n                }\n\n                var treePtr = ExtractTreePtr(stubSpan);\n                if (treePtr == 0)\n                {\n                    result = RangeIndexResult.Error;\n                    errorMsg = \"ERR no such range index\"u8;\n                    return GarnetStatus.OK;\n                }\n\n                var insertResult = BfTreeService.InsertByPtr(treePtr, field, value);\n                if (insertResult == BfTreeInsertResult.InvalidArguments)\n                {\n                    logger?.LogError(\"RI.SET: invalid arguments for a {keyLen}-byte field and {valueLen}-byte value.\", field.Length, value.Length);\n                    throw new GarnetException(\"RI.SET: invalid arguments.\");\n                }\n\n                if (insertResult == BfTreeInsertResult.InvalidKV)\n                {\n                    ref readonly var stub = ref RangeIndexManager.ReadIndex(stubSpan);\n                    result = RangeIndexResult.Error;\n                    errorMsg = System.Text.Encoding.UTF8.GetBytes(\n                        $\"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})\");\n                    return GarnetStatus.OK;\n                }\n\n                result = RangeIndexResult.OK;\n\n                functionsState.rangeIndexManager.ReplicateRangeIndexSet(\n                    key, field, value, functionsState.appendOnlyFile,\n                    stringBasicContext.Session.Version, stringBasicContext.Session.ID,\n                    functionsState.StoredProcMode);\n","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Storage/Session/MainStore/RangeIndexOps.cs#L210-L246","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nRI.SET myindex \"\" \"value\"\n\n// after\nRI.SET myindex \"field1\" \"value\"","handlingStrategy":"validation","validationCode":"if (field == null || field.Length == 0)\n    throw new ArgumentException(\"RI.SET field must be non-empty.\");\nif (value == null || value.Length == 0)\n    throw new ArgumentException(\"RI.SET value must be non-empty.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["range-index","bftree","ri-set","runtime","garnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}