{"record":{"id":"5d08f8d2fd44fc0e","repo":"microsoft/garnet","slug":"maxinlinekeysize-value-maxinlinekeysize-size","errorCode":null,"errorMessage":"MaxInlineKeySize value '{MaxInlineKeySize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.","messagePattern":"MaxInlineKeySize value '(.+?)' \\((.+?) bytes\\) is outside the allowed range \\[(.+?), (.+?)\\] bytes\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":901,"sourceCode":"        /// <summary>\n        /// Parse <see cref=\"MaxInlineKeySize\"/> as a byte count.\n        /// Returns the default value (1022 bytes, the Tsavorite limit) if the value is null or empty.\n        /// </summary>\n        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineKeySize</c>.</returns>\n        /// <exception cref=\"Exception\">Thrown when the value cannot be parsed or is outside the allowed range.</exception>\n        public int MaxInlineKeySizeBytes()\n        {\n            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize\n            const long MaxBytes = 1022;                 // TODO: LogSettings.MaxInlineKeySizeLimit (= (1 << kKeyLengthBits) - 2)\n\n            if (string.IsNullOrEmpty(MaxInlineKeySize))\n                return KVSettings.DefaultMaxInlineKeySize;\n\n            if (!TryParseSize(MaxInlineKeySize, out var sizeInBytes))\n                throw new Exception($\"Unable to parse {nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}'. Expected a memory size string (e.g. '1k', '128').\");\n\n            if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)\n                throw new Exception($\"{nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.\");\n\n            return (int)sizeInBytes;\n        }\n\n        /// <summary>\n        /// Parse and validate <see cref=\"MaxInlineValueSize\"/> as a byte count.\n        /// Tsavorite requires this to be at most 0xFFFFFE (the RecordDataHeader value-length field's\n        /// inline limit; see <c>LogSettings.MaxInlineValueSizeLimit</c> — this value MUST be kept in sync because LogSettings\n        /// is internal to Tsavorite.core and not visible from Garnet.server). If this value is not specified, it defaults\n        /// to the minimum of 1m or <paramref name=\"pageSize\"/> / 2; otherwise, the value must be &lt;= pageSize / 2.\n        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineValueSize</c>.</returns>\n        /// <exception cref=\"Exception\">Thrown when the value cannot be parsed or is outside the allowed byte range.</exception>\n        /// </summary>\n        public int MaxInlineValueSizeBytes(long pageSize)\n        {\n            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize\n            const long MaxBytes = 0xFFFFFE;             // TODO: LogSettings.MaxInlineValueSizeLimit (= (1 << kValueLengthBits) - 2)\n","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L883-L919","documentation":"After parsing, MaxInlineKeySize must fall within [0, 1022] bytes. The 1022-byte upper bound mirrors Tsavorite's LogSettings.MaxInlineKeySizeLimit ((1 << kKeyLengthBits) - 2), which is the largest key that can be stored inline in the in-memory record header. Values above 1022 cannot be inlined and must go through the object log.","triggerScenarios":"Setting --max-inline-key-size to a value > 1022 (e.g. '2k' = 2048) or a negative value. Thrown at GarnetServerOptions.cs:900-901.","commonSituations":"Assuming keys can be arbitrarily large inline; copying a config expecting kilobyte-scale inline keys; misunderstanding that large keys spill to the object log regardless.","solutions":["Keep --max-inline-key-size <= 1022 bytes (the default is already 1022).","Leave the flag unset to use the default, which is the maximum allowed.","If you have larger keys, accept that they will be stored via the object log rather than raising this limit."],"exampleFix":"# before (fails: 2k > 1022)\ngarnet-server --max-inline-key-size 2k\n\n# after\ngarnet-server --max-inline-key-size 1022   # or omit the flag","handlingStrategy":"validation","validationCode":"const long MaxInlineKey = 1022;\nif (ServerOptions.TryParseSize(options.MaxInlineKeySize, out var k) && (k < 0 || k > MaxInlineKey)) {\n    throw new ArgumentOutOfRangeException($\"MaxInlineKeySize must be in [0, {MaxInlineKey}]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep inline keys <= 1022 bytes; accept larger keys spill to the object log.","Omit the flag to use the safe default."],"tags":["garnet","config","tsavorite","storage","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}