diff --git a/.changelog/5408.bugfix.md b/.changelog/5408.bugfix.md new file mode 100644 index 00000000000..27161f2144f --- /dev/null +++ b/.changelog/5408.bugfix.md @@ -0,0 +1 @@ +Fix showing empty peer IDs in the Consensus light client status output diff --git a/go/consensus/cometbft/light/p2p/p2p.go b/go/consensus/cometbft/light/p2p/p2p.go index d4c25b64803..de3ad54d1e4 100644 --- a/go/consensus/cometbft/light/p2p/p2p.go +++ b/go/consensus/cometbft/light/p2p/p2p.go @@ -189,6 +189,8 @@ func (lp *lightClientProvider) Initialized() <-chan struct{} { func (lp *lightClientProvider) PeerID() string { peer := lp.getPeer() if peer == nil { + // This happens if a provider is not yet initialized, or + // (less likely) if a peer was just dropped and no new peer is available. return "" } return peer.String() diff --git a/go/consensus/cometbft/light/service.go b/go/consensus/cometbft/light/service.go index f1d076600ca..9b1455407c5 100644 --- a/go/consensus/cometbft/light/service.go +++ b/go/consensus/cometbft/light/service.go @@ -106,7 +106,9 @@ func (c *client) GetStatus() (*consensus.LightClientStatus, error) { } for _, p := range c.providers { - status.PeerIDs = append(status.PeerIDs, p.PeerID()) + if id := p.PeerID(); id != "" { + status.PeerIDs = append(status.PeerIDs, id) + } } return status, nil