state: report unindexed node key instead of panicking

A missing key yields the zero NodeView; its ID() panicked inside a reader
goroutine and took down the test binary instead of failing with a diagnostic.
This commit is contained in:
Kristoffer Dalby
2026-09-30 16:39:31 +00:00
committed by Kristoffer Dalby
parent 85bda7c2c9
commit 541ef40c87
+7 -2
View File
@@ -2449,9 +2449,14 @@ func nodeKeyIndexMismatch(snap *Snapshot) string {
}
for _, nv := range snap.allNodes {
// A missing key yields the zero view, whose ID() panics.
got, ok := snap.nodesByNodeKey[nv.NodeKey()]
if !ok || got.ID() != nv.ID() {
return fmt.Sprintf("node %d: key indexed=%t id=%d", nv.ID(), ok, got.ID())
if !ok {
return fmt.Sprintf("node %d: key not indexed", nv.ID())
}
if got.ID() != nv.ID() {
return fmt.Sprintf("node %d: key indexed to node %d", nv.ID(), got.ID())
}
}