{"record":{"id":"947c6f779d6083b9","repo":"microsoft/garnet","slug":"err-value-is-not-an-integer-or-out-of-range","errorCode":null,"errorMessage":"ERR value is not an integer or out of range.","messagePattern":"ERR value is not an integer or out of range\\.","errorType":"exception","errorClass":"GarnetException","httpStatus":null,"severity":"error","filePath":"libs/server/Resp/Bitmap/BitmapManager.cs","lineNumber":105,"sourceCode":"                ? MaxOffsetForBitmapLength\n                : MaxBitmapPayloadBytes - 1L;\n\n            if (startOffset < -maxOffset)\n                startOffset = -maxOffset;\n            else if (startOffset > maxOffset)\n                startOffset = maxOffset;\n\n            if (endOffset < -maxOffset)\n                endOffset = -maxOffset;\n            else if (endOffset > maxOffset)\n                endOffset = maxOffset;\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private static int Index(long offset)\n        {\n            if (!IsValidBitOffset(offset))\n                throw new GarnetException(\"ERR value is not an integer or out of range.\");\n            return (int)(offset >> 3);\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private static int LengthInBytes(long offset)\n        {\n            if (!TryValidateLengthInBytes(offset, out var lengthInBytes))\n                throw new GarnetException(\"ERR value is not an integer or out of range.\");\n            return lengthInBytes;\n        }\n\n        /// <summary>\n        /// Check to see if offset contained by value size\n        /// </summary>\n        /// <param name=\"vlen\"></param>\n        /// <param name=\"offset\"></param>\n        /// <returns></returns>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Resp/Bitmap/BitmapManager.cs#L87-L123","documentation":"Thrown by the internal Index(long offset) helper when IsValidBitOffset(offset) is false - i.e., the bit offset exceeds MaxOffsetForBitmapLength (512 MiB x 8 - 1, about 4.29e9). The message is the standard Redis error string, so to a RESP client it looks like the familiar integer/range error. Index converts a bit offset to a byte index and rejects out-of-range offsets.","triggerScenarios":"A bitmap operation computes a byte index from a bit offset beyond the 512 MiB-payload cap (or otherwise out of range). The bitfield commands pre-validate via TryValidateBitfieldOffset, so reaching this throw means a path that skipped/bypassed that validation, or an internal invariant violation.","commonSituations":"A client sends a BITFIELD/bitmap offset so large it exceeds the maximum bitmap payload; an internal caller passing an unvalidated offset.","solutions":["Reduce the requested offset below MaxBitmapPayloadBytes * 8 - 1 (512 MiB x 8 - 1).","If you call bitmap internals from extension code, validate the offset with BitmapManager.IsValidBitOffset first.","Check that you are on a current Garnet build - older builds had thinner pre-validation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const long MaxBitOffset = (512L * 1024 * 1024 * 8) - 1;\nif (offset < 0 || offset > MaxBitOffset)\n    return BadRequest(\"ERR value is not an integer or out of range.\");","typeGuard":null,"tryCatchPattern":"catch (GarnetException ex) when (ex.Message == \"ERR value is not an integer or out of range.\") {\n    // Map to a normal client error; do not treat as a server crash\n    return BadRequest(ex.Message);\n}","preventionTips":["Clamp/validate offsets against the 512 MiB bitmap limit before sending bitmap commands.","For BITFIELD, prefer #-prefixed offsets and validate bit counts."],"tags":["bitmap","validation","offset","redis-error"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}