[management] handle nil ptr in sendInitialSync() when the peer is deleted (#7315)

* fix a nil-ptr error occuring in sendInitialSync when the peer being synced is deleted

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>

* handle a nil ptr in GetPeerNetworkMapComponents

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>

---------

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
dmitri-netbird
2026-08-25 16:14:17 +02:00
committed by GitHub
parent 7d83a3902d
commit c512bf25aa
8 changed files with 261 additions and 3 deletions
@@ -112,8 +112,6 @@ func (a *Account) GetPeerNetworkMapComponents(
return EmptyNetworkMapComponents(&NetworkMapComponents{
PeerID: peerID,
Network: a.Network.Copy(),
// must include the target peer as it's required on the client
Peers: map[string]*ComponentPeer{peerID: peer.ToComponent()},
})
}
@@ -0,0 +1,20 @@
package types
import (
"context"
"testing"
"github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/shared/management/types"
"github.com/stretchr/testify/assert"
)
func TestGetPeerNetworkMapComponents_PeerMissingFromAcount(t *testing.T) {
account := Account{Network: NewNetwork()}
nmapcomponets := account.GetPeerNetworkMapComponents(context.TODO(), "missing-peer", dns.CustomZone{}, nil, nil, nil, nil, nil)
assert.Equal(t, EmptyNetworkMapComponents(&types.NetworkMapComponents{
PeerID: "missing-peer",
Network: account.Network,
}), nmapcomponets)
}