{"record":{"id":"cd941dbd671c4404","repo":"nats-io/nats-server","slug":"thw-encoded-version-not-known","errorCode":null,"errorMessage":"thw: encoded version not known","messagePattern":"thw: encoded version not known","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/thw/thw.go","lineNumber":28,"sourceCode":"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage thw\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"io\"\n\t\"math\"\n\t\"time\"\n)\n\n// Error for when we can not locate a task for removal or updates.\nvar ErrTaskNotFound = errors.New(\"thw: task not found\")\n\n// Error for when we try to decode a binary-encoded THW with an unknown version number.\nvar ErrInvalidVersion = errors.New(\"thw: encoded version not known\")\n\nconst (\n\ttickDuration = int64(time.Second) // Tick duration in nanoseconds.\n\twheelBits    = 12                 // 2^12 = 4096 slots.\n\twheelSize    = 1 << wheelBits     // Number of slots in the wheel.\n\twheelMask    = wheelSize - 1      // Mask for calculating position.\n\theaderLen    = 17                 // 1 byte magic + 2x uint64s\n)\n\n// slot represents a single slot in the wheel.\ntype slot struct {\n\tentries map[uint64]int64 // Map of sequence to expires.\n\tlowest  int64            // Lowest expiration time in this slot.\n}\n\n// HashWheel represents the timing wheel.\ntype HashWheel struct {\n\twheel  []*slot // Array of slots.","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/thw/thw.go#L10-L46","documentation":"Binary decode of a timing-wheel snapshot: the version byte is not 1 (the only supported encoding version), so the buffer cannot be interpreted and decode aborts before reading any entries. The version byte of the encoded blob is the input at fault.","triggerScenarios":"Thrown at server/thw/thw.go:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-encode the wheel snapshot using version 1","Regenerate the persisted state instead of decoding incompatible data","Extend the decoder if a newer encoding version was introduced"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}