{"record":{"id":"92406999caf6b665","repo":"nats-io/nats-server","slug":"snapshot-corrupt-too-short","errorCode":null,"errorMessage":"Snapshot corrupt, too short","messagePattern":"Snapshot corrupt, too short","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/raft.go","lineNumber":2035,"sourceCode":"}\n\n// loadLastSnapshot will load and return our last snapshot.\n// Lock should be held.\nfunc (n *raft) loadLastSnapshot() (*snapshot, error) {\n\tif n.snapfile == _EMPTY_ {\n\t\treturn nil, errNoSnapAvailable\n\t}\n\n\tn.dios.acquire()\n\tbuf, err := os.ReadFile(n.snapfile)\n\tn.dios.release()\n\n\tif err != nil {\n\t\tn.warn(\"Error reading snapshot: %v\", err)\n\t\treturn nil, err\n\t}\n\tif len(buf) < minSnapshotLen {\n\t\tn.warn(\"Snapshot corrupt, too short\")\n\t\treturn nil, errSnapshotCorrupt\n\t}\n\n\t// Check to make sure hash is consistent.\n\thoff := len(buf) - 8\n\tlchk := buf[hoff:]\n\tn.hh.Reset()\n\tn.hh.Write(buf[:hoff])\n\tvar hb [highwayhash.Size64]byte\n\tif !bytes.Equal(lchk[:], n.hh.Sum(hb[:0])) {\n\t\tn.warn(\"Snapshot corrupt, checksums did not match\")\n\t\treturn nil, errSnapshotCorrupt\n\t}\n\n\tvar le = binary.LittleEndian\n\tlps := le.Uint32(buf[16:])\n\tsnap := &snapshot{\n\t\tlastTerm:  le.Uint64(buf[0:]),","sourceCodeStart":2017,"sourceCodeEnd":2053,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/raft.go#L2017-L2053","documentation":"A warning logged by raft.loadLastSnapshot() when the snapshot file read succeeds but is shorter than minSnapshotLen, meaning it is truncated or corrupt. errSnapshotCorrupt is returned, so the snapshot cannot be used for state restoration and the node must recover via WAL or peers.","triggerScenarios":"Thrown at server/raft.go:2035 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the snapshot as corrupt; remove it so an older snapshot/WAL is used","Check for interrupted writes or disk corruption in the raft storage directory","Resync the node from a healthy peer if no valid snapshot exists","Ensure the storage volume is not filling up or being truncated externally"],"exampleFix":null,"handlingStrategy":"fallback","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"}