{"record":{"id":"187e602094b0f708","repo":"microsoft/garnet","slug":"unable-to-parse-maxinlinevaluesize-value-maxinli","errorCode":null,"errorMessage":"Unable to parse MaxInlineValueSize value '{MaxInlineValueSize}'. Expected a memory size string (e.g. '4k', '16m').","messagePattern":"Unable to parse MaxInlineValueSize value '(.+?)'\\. Expected a memory size string \\(e\\.g\\. '4k', '16m'\\)\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":924,"sourceCode":"        /// <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\n            if (string.IsNullOrEmpty(MaxInlineValueSize))\n                return (int)Math.Min(pageSize / 2, KVSettings.DefaultMaxInlineValueSize);\n\n            if (!TryParseSize(MaxInlineValueSize, out var sizeInBytes))\n                throw new Exception($\"Unable to parse {nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}'. Expected a memory size string (e.g. '4k', '16m').\");\n\n            if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)\n                throw new Exception($\"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.\");\n\n            // This check guarantees at least one record fits on a page, because the minimum page size is 4k, and 2k is larger than\n            // the PageHeader plus non-value components of a record (RecordInfo, RecordDataHeader, Key, and possible Optional fields).\n            if (sizeInBytes > pageSize / 2)\n                throw new Exception($\"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is greater than half the page size ({pageSize / 2} bytes for PageSize {pageSize} bytes).\");\n\n            return (int)sizeInBytes;\n        }\n\n        /// <summary>\n        /// Parse <see cref=\"InitialIORecordSize\"/> as a byte count.\n        /// Returns <see cref=\"KVSettings.UseDefaultInitialIORecordSize\"/> if the value is null or empty (use default).\n        /// </summary>\n        /// <returns>The byte value used for <c>KVSettings.InitialIORecordSize</c>, or <see cref=\"KVSettings.UseDefaultInitialIORecordSize\"/> if unset.</returns>\n        /// <exception cref=\"Exception\">Thrown when the value cannot be parsed.</exception>","sourceCodeStart":906,"sourceCodeEnd":942,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L906-L942","documentation":"MaxInlineValueSizeBytes() parses the MaxInlineValueSize option with the same TryParseSize rules as the key variant (bare integer or integer + k/m/g/t/p suffix, optionally 'b'). A string that cannot be fully consumed by the parser is rejected at startup.","triggerScenarios":"Setting --max-inline-value-size to a non-conforming string such as '16 MB', '0x10', '1.5m', or 'abc'. Thrown at GarnetServerOptions.cs:923-924.","commonSituations":"Including a space between number and unit ('16 MB'); using hex; typos; unsupported unit spellings.","solutions":["Use the accepted forms: '4k', '16m', '1g', '512', etc.","Drop spaces and avoid units outside k/m/g/t/p.","Omit the flag to use the default of min(pageSize/2, DefaultMaxInlineValueSize)."],"exampleFix":"# before (fails)\ngarnet-server --max-inline-value-size '16 MB'\n\n# after\ngarnet-server --max-inline-value-size 16m","handlingStrategy":"validation","validationCode":"static bool IsValidSizeString(string s) => string.IsNullOrEmpty(s) || ServerOptions.TryParseSize(s, out _);\nif (!IsValidSizeString(options.MaxInlineValueSize)) {\n    throw new ArgumentException(\"MaxInlineValueSize must be like '4k' or '16m'\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use accepted size forms only; avoid '16 MB' style with spaces.","Centralize size parsing/validation for all size-string knobs."],"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"}