microsoft/garnet · error · Exception
Unable to parse MaxInlineKeySize value '{MaxInlineKeySize}'.
Error message
Unable to parse MaxInlineKeySize value '{MaxInlineKeySize}'. Expected a memory size string (e.g. '1k', '128'). What it means
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.
Source
Thrown at libs/server/Servers/GarnetServerOptions.cs:898
/// </summary>
internal int ReadCachePageSizeBits() => ValidatedPageSizeBits(ReadCachePageSize, nameof(ReadCachePageSize));
/// <summary>
/// Parse <see cref="MaxInlineKeySize"/> as a byte count.
/// Returns the default value (1022 bytes, the Tsavorite limit) if the value is null or empty.
/// </summary>
/// <returns>The byte-length value used for <c>KVSettings.MaxInlineKeySize</c>.</returns>
/// <exception cref="Exception">Thrown when the value cannot be parsed or is outside the allowed range.</exception>
public int MaxInlineKeySizeBytes()
{
const long MinBytes = 0; // TODO: LogSettings.MinMaxInlineSize
const long MaxBytes = 1022; // TODO: LogSettings.MaxInlineKeySizeLimit (= (1 << kKeyLengthBits) - 2)
if (string.IsNullOrEmpty(MaxInlineKeySize))
return KVSettings.DefaultMaxInlineKeySize;
if (!TryParseSize(MaxInlineKeySize, out var sizeInBytes))
throw new Exception($"Unable to parse {nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}'. Expected a memory size string (e.g. '1k', '128').");
if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)
throw new Exception($"{nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.");
return (int)sizeInBytes;
}
/// <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 <= 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)
{View on GitHub (pinned to 951b0fc683)
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).
Example fix
# before (fails) garnet-server --max-inline-key-size 0x80 # after garnet-server --max-inline-key-size 128
Defensive patterns
Strategy: validation
Validate before calling
static bool IsValidSizeString(string s) {
if (string.IsNullOrEmpty(s)) return true;
return ServerOptions.TryParseSize(s, out _);
}
if (!IsValidSizeString(options.MaxInlineKeySize)) {
throw new ArgumentException("MaxInlineKeySize must be like '128' or '1k'");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Typos; using hex or binary notation; locale-specific formatting; stray whitespace or units the parser does not recognize (e.g. '12 bytes').
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse MaxInlineValueSize value '{MaxInlineValueSiz
- Unable to parse InitialIORecordSize value '{InitialIORecordS
- MutablePercent must be between 10 and 95
- Store Log Memory size or PageCount must be specified
- Index size {IndexMemorySize} should not be less than index m
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/01f08b6c5f0be616.
Report an issue: GitHub.