{"record":{"id":"2b39485dc339b5e2","repo":"microsoft/garnet","slug":"type-not-supported-headertype","errorCode":null,"errorMessage":"Type not supported {headerType}","messagePattern":"Type not supported (.+?)","errorType":"exception","errorClass":"GarnetException","httpStatus":null,"severity":"critical","filePath":"libs/server/AOF/AofHeader.cs","lineNumber":137,"sourceCode":"    };\n\n    /// <summary>\n    /// Basic AOF header\n    /// </summary>\n    [StructLayout(LayoutKind.Explicit, Size = TotalSize)]\n    struct AofHeader\n    {\n        public static unsafe byte* SkipHeader(byte* entryPtr)\n        {\n            var header = *(AofHeader*)entryPtr;\n            var headerType = header.HeaderType;\n            return headerType switch\n            {\n                AofHeaderType.BasicHeader => entryPtr + TotalSize,\n                AofHeaderType.ShardedHeader => entryPtr + AofShardedHeader.TotalSize,\n                AofHeaderType.ShardedLogTransactionHeader => entryPtr + AofShardedLogTransactionHeader.TotalSize,\n                AofHeaderType.SingleLogTransactionHeader => entryPtr + AofSingleLogTransactionHeader.TotalSize,\n                _ => throw new GarnetException($\"Type not supported {headerType}\"),\n            };\n        }\n\n        public const int TotalSize = 16;\n\n        // Important: Update AofHeaderVersion whenever any of the following change:\n        // * Layout, size, contents of this struct\n        // * Any of the AofEntryType or AofStoreType enums' existing value mappings\n        // * SpanByte format or header\n        // * The persisted-value numbering of any enum serialized into an entry payload:\n        //   RespCommand (RespInputHeader.cmd), the object sub-operation enums (RespInputHeader.SubId:\n        //   HashOperation/ListOperation/SetOperation/SortedSetOperation), GarnetObjectType\n        //   (RespInputHeader.type), or RespInputFlags.\n        // * The layout of RespInputHeader itself (e.g. which byte holds cmd/type/subId/flags).\n        // Version 3 repurposes the flags byte as a bitfield containing the header type\n        // plus chunked-record and unsafe-truncate markers.\n        // Version 4 makes the RespCommand write block dense/explicit (writes-first) and moves the\n        // object sub-operation id (SubId) from the low 5 bits of the flags byte into its own header","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/AOF/AofHeader.cs#L119-L155","documentation":"Thrown by AofHeader.SkipHeader(byte* entryPtr) when the 2-bit HeaderType field read from a raw AOF entry does not match any known AofHeaderType (BasicHeader=0, ShardedHeader=1, SingleLogTransactionHeader=2, ShardedLogTransactionHeader=3). Since the type field is only 2 bits, an unknown value implies memory corruption, a misaligned pointer, or reading non-AOF data as an AOF entry.","triggerScenarios":"SkipHeader is called with a pointer that doesn't actually point at a valid AofHeader — for example, a corrupted log entry, an address past the end of valid data, or data from a different store layout. The switch exhausts all four legal enum values, so any other bit pattern hits the default.","commonSituations":"AOF file or memory page corruption; a Garnet downgrade or layout mismatch where the on-disk struct layout differs from what this build expects; a bug causing an incorrect pointer arithmetic before calling SkipHeader.","solutions":["Verify the AOF data was produced by a compatible Garnet build (same struct layout, same AofHeaderVersion).","Check for disk/memory corruption — run on a clean checkpoint and AOF, or restore from backup.","If the data is from an older build, use the matching Garnet version to replay it rather than a mismatched build.","Investigate the caller: ensure the pointer is aligned to a real AOF entry boundary."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ptr = AofHeader.SkipHeader(ptr); }\ncatch (GarnetException ex)\n{\n    logger.LogCritical(ex, \"AOF header type {Type} unrecognized at offset {Offset}\", header.HeaderType, offset);\n    // halt recovery; do not continue scanning past corruption\n    throw;\n}","preventionTips":["Ensure AOF data is produced and replayed by Garnet builds with the same header layout.","Back up checkpoint+AOF before replay so corruption is recoverable.","Monitor disk health to catch silent corruption early."],"tags":["aof","data-corruption","replay","internal"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}