microsoft/garnet · error · Exception

Unable to parse MaxInlineValueSize value '{MaxInlineValueSiz

Error message

Unable to parse MaxInlineValueSize value '{MaxInlineValueSize}'. Expected a memory size string (e.g. '4k', '16m').

What it means

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.

Source

Thrown at libs/server/Servers/GarnetServerOptions.cs:924

        /// <summary>
        /// Parse and validate <see cref="MaxInlineValueSize"/> as a byte count.
        /// Tsavorite requires this to be at most 0xFFFFFE (the RecordDataHeader value-length field's
        /// inline limit; see <c>LogSettings.MaxInlineValueSizeLimit</c> — this value MUST be kept in sync because LogSettings
        /// is internal to Tsavorite.core and not visible from Garnet.server). If this value is not specified, it defaults
        /// to the minimum of 1m or <paramref name="pageSize"/> / 2; otherwise, the value must be &lt;= pageSize / 2.
        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineValueSize</c>.</returns>
        /// <exception cref="Exception">Thrown when the value cannot be parsed or is outside the allowed byte range.</exception>
        /// </summary>
        public int MaxInlineValueSizeBytes(long pageSize)
        {
            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize
            const long MaxBytes = 0xFFFFFE;             // TODO: LogSettings.MaxInlineValueSizeLimit (= (1 << kValueLengthBits) - 2)

            if (string.IsNullOrEmpty(MaxInlineValueSize))
                return (int)Math.Min(pageSize / 2, KVSettings.DefaultMaxInlineValueSize);

            if (!TryParseSize(MaxInlineValueSize, out var sizeInBytes))
                throw new Exception($"Unable to parse {nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}'. Expected a memory size string (e.g. '4k', '16m').");

            if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)
                throw new Exception($"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.");

            // This check guarantees at least one record fits on a page, because the minimum page size is 4k, and 2k is larger than
            // the PageHeader plus non-value components of a record (RecordInfo, RecordDataHeader, Key, and possible Optional fields).
            if (sizeInBytes > pageSize / 2)
                throw new Exception($"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is greater than half the page size ({pageSize / 2} bytes for PageSize {pageSize} bytes).");

            return (int)sizeInBytes;
        }

        /// <summary>
        /// Parse <see cref="InitialIORecordSize"/> as a byte count.
        /// Returns <see cref="KVSettings.UseDefaultInitialIORecordSize"/> if the value is null or empty (use default).
        /// </summary>
        /// <returns>The byte value used for <c>KVSettings.InitialIORecordSize</c>, or <see cref="KVSettings.UseDefaultInitialIORecordSize"/> if unset.</returns>
        /// <exception cref="Exception">Thrown when the value cannot be parsed.</exception>

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Use the accepted forms: '4k', '16m', '1g', '512', etc.
  2. Drop spaces and avoid units outside k/m/g/t/p.
  3. Omit the flag to use the default of min(pageSize/2, DefaultMaxInlineValueSize).

Example fix

# before (fails)
garnet-server --max-inline-value-size '16 MB'

# after
garnet-server --max-inline-value-size 16m
Defensive patterns

Strategy: validation

Validate before calling

static bool IsValidSizeString(string s) => string.IsNullOrEmpty(s) || ServerOptions.TryParseSize(s, out _);
if (!IsValidSizeString(options.MaxInlineValueSize)) {
    throw new ArgumentException("MaxInlineValueSize must be like '4k' or '16m'");
}

Prevention

When it happens

Trigger: 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.

Common situations: Including a space between number and unit ('16 MB'); using hex; typos; unsupported unit spellings.

Understand the failure class

Related errors


AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13). Data as JSON: /api/errors/187e602094b0f708. Report an issue: GitHub.