{"record":{"id":"01f08b6c5f0be616","repo":"microsoft/garnet","slug":"unable-to-parse-maxinlinekeysize-value-maxinline","errorCode":null,"errorMessage":"Unable to parse MaxInlineKeySize value '{MaxInlineKeySize}'. Expected a memory size string (e.g. '1k', '128').","messagePattern":"Unable to parse MaxInlineKeySize value '(.+?)'\\. Expected a memory size string \\(e\\.g\\. '1k', '128'\\)\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":898,"sourceCode":"        /// </summary>\n        internal int ReadCachePageSizeBits() => ValidatedPageSizeBits(ReadCachePageSize, nameof(ReadCachePageSize));\n\n        /// <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        {","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L880-L916","documentation":"MaxInlineKeySizeBytes() parses the MaxInlineKeySize option via TryParseSize, which accepts a bare integer or an integer with a k/m/g/t/p suffix (optionally followed by 'b'). If the parser cannot consume the entire string (trailing characters, non-numeric prefix, embedded symbols like '.' or 'x'), the value is rejected. This runs before store init so it fails fast at startup.","triggerScenarios":"Setting --max-inline-key-size to a non-conforming string such as 'abc', '0x10', '1.5k', '1 k', or '12-'. Thrown at GarnetServerOptions.cs:897-898.","commonSituations":"Typos; using hex or binary notation; locale-specific formatting; stray whitespace or units the parser does not recognize (e.g. '12 bytes').","solutions":["Use a plain integer or integer+suffix form: '128', '1k', '1kb', '1K' are all valid.","Remove trailing spaces and avoid units other than k/m/g/t/p.","If you do not need to override the default, omit the flag (defaults to KVSettings.DefaultMaxInlineKeySize)."],"exampleFix":"# before (fails)\ngarnet-server --max-inline-key-size 0x80\n\n# after\ngarnet-server --max-inline-key-size 128","handlingStrategy":"validation","validationCode":"static bool IsValidSizeString(string s) {\n    if (string.IsNullOrEmpty(s)) return true;\n    return ServerOptions.TryParseSize(s, out _);\n}\nif (!IsValidSizeString(options.MaxInlineKeySize)) {\n    throw new ArgumentException(\"MaxInlineKeySize must be like '128' or '1k'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use plain integers or integer+k/m/g/t/p only; avoid spaces, hex, and 'bytes'.","Validate size strings in config-load code with TryParseSize."],"tags":["garnet","config","tsavorite","parsing","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}