From 541ef40c87e56482c27bf538ac5c547b958f38aa Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Wed, 30 Sep 2026 16:39:31 +0000 Subject: [PATCH] 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. --- hscontrol/state/node_store_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hscontrol/state/node_store_test.go b/hscontrol/state/node_store_test.go index f405eba1d..8d07eaf03 100644 --- a/hscontrol/state/node_store_test.go +++ b/hscontrol/state/node_store_test.go @@ -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()) } }