microsoft/garnet · error · Exception
Option {fileType} not supported
Error message
Option {fileType} not supported What it means
Thrown by CheckpointEntry.ContainsSharedToken when fileType is neither STORE_HLOG nor STORE_INDEX. The method compares only those two token kinds, so other CheckpointFileType values (e.g. STORE_SNAPSHOT, STORE_HLOG_OBJ) are unsupported for shared-token comparison.
Source
Thrown at libs/cluster/Server/Replication/CheckpointEntry.cs:96
/// </summary>
/// <returns>(true) if operation succeeded, (false) otherwise</returns>
public bool TrySuspendReaders()
=> _lock.IsWriteLocked || _lock.TryWriteLock();
/// <summary>
/// Compare tokens for specified CheckpointFileType
/// </summary>
/// <param name="entry"></param>
/// <param name="fileType"></param>
/// <returns>(true) if token is shared between entries, (false) otherwise</returns>
/// <exception cref="Exception"></exception>
public bool ContainsSharedToken(CheckpointEntry entry, CheckpointFileType fileType)
{
return fileType switch
{
CheckpointFileType.STORE_HLOG => metadata.storeHlogToken.Equals(entry.metadata.storeHlogToken),
CheckpointFileType.STORE_INDEX => metadata.storeIndexToken.Equals(entry.metadata.storeIndexToken),
_ => throw new Exception($"Option {fileType} not supported")
};
}
/// <summary>
/// Serialize CheckpointEntry
/// </summary>
/// <returns></returns>
public byte[] ToByteArray()
{
var ms = new MemoryStream();
var writer = new BinaryWriter(ms, Encoding.ASCII);
// Write checkpoint entry data for main store
writer.Write(metadata.storeVersion);
writer.Write(metadata.storeHlogToken.ToByteArray());
writer.Write(metadata.storeIndexToken.ToByteArray());
metadata.storeCheckpointCoveredAofAddress.Serialize(writer);
writer.Write(metadata.storePrimaryReplId == null ? 0 : 1);View on GitHub (pinned to 951b0fc683)
Solutions
- Call ContainsSharedToken only for STORE_HLOG or STORE_INDEX file types.
- If snapshot/object tokens need shared comparison, extend the switch with the relevant arms and token fields.
- Guard the caller to skip or branch on unsupported file types rather than passing them through.
Defensive patterns
Strategy: validation
Validate before calling
// Only compare shared tokens for supported file types
if (fileType is not (CheckpointFileType.STORE_HLOG or CheckpointFileType.STORE_INDEX))
throw new ArgumentOutOfRangeException(nameof(fileType), fileType, "Shared-token comparison supports STORE_HLOG/STORE_INDEX only");
return entryA.ContainsSharedToken(entryB, fileType); Prevention
- Restrict ContainsSharedToken callers to STORE_HLOG/STORE_INDEX.
- Extend the switch (and token fields) when adding file types that need shared comparison.
- Document supported file types on the method.
When it happens
Trigger: Calling ContainsSharedToken with a snapshot or object-log file type, or an out-of-range CheckpointFileType cast.
Common situations: A checkpoint-replication code path that asks to share a token for a snapshot file when only hlog/index tokens are tracked for sharing; extending checkpoint types without extending this comparison.
Related errors
- RetrieveCheckpointFile: unexpected state{retStateType}
- Checkpoint history unavailable, need full checkpoint for {en
- Failed to validate main store metadata at insertion
- invalid metadata length: {hlri.cookie.Length} < 4
- invalid metadata length: {hlri.cookie.Length} < 12
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/57d2c09291bd1c3a.
Report an issue: GitHub.