{"record":{"id":"2165cc96ca96deea","repo":"nats-io/nats-server","slug":"bad-ack-floor-for-stream-2165cc","errorCode":null,"errorMessage":"bad ack floor for stream","messagePattern":"bad ack floor for stream","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/memstore.go","lineNumber":2765,"sourceCode":"\t\t// Skip if beyond our current state.\n\t\tif first, _, _ := db.State(); first > lseq {\n\t\t\tcontinue\n\t\t}\n\t\tdb.Range(func(seq uint64) bool {\n\t\t\tms.removeMsg(seq, false)\n\t\t\treturn true\n\t\t})\n\t}\n\treturn nil\n}\n\nfunc (o *consumerMemStore) Update(state *ConsumerState) error {\n\t// Sanity checks.\n\tif state.AckFloor.Consumer > state.Delivered.Consumer {\n\t\treturn fmt.Errorf(\"bad ack floor for consumer\")\n\t}\n\tif state.AckFloor.Stream > state.Delivered.Stream {\n\t\treturn fmt.Errorf(\"bad ack floor for stream\")\n\t}\n\n\t// Copy to our state.\n\tvar pending map[uint64]*Pending\n\tvar redelivered map[uint64]uint64\n\tif len(state.Pending) > 0 {\n\t\tpending = make(map[uint64]*Pending, len(state.Pending))\n\t\tfor seq, p := range state.Pending {\n\t\t\tpending[seq] = &Pending{p.Sequence, p.Timestamp}\n\t\t\tif seq <= state.AckFloor.Stream || seq > state.Delivered.Stream {\n\t\t\t\treturn fmt.Errorf(\"bad pending entry, sequence [%d] out of range\", seq)\n\t\t\t}\n\t\t}\n\t}\n\tif len(state.Redelivered) > 0 {\n\t\tredelivered = make(map[uint64]uint64, len(state.Redelivered))\n\t\tfor seq, dc := range state.Redelivered {\n\t\t\tredelivered[seq] = dc","sourceCodeStart":2747,"sourceCodeEnd":2783,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/memstore.go#L2747-L2783","documentation":"Sanity check in consumerMemStore.Update: the stream-sequence AckFloor is greater than the Delivered stream sequence — more stream messages acknowledged than delivered. Rejects corrupted or hand-crafted ConsumerState payloads before they overwrite local state.","triggerScenarios":"Thrown at server/memstore.go:2765 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the incoming ConsumerState before calling Update","Recreate the consumer if replicated state is inconsistent"],"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"}