From 572970d25577d87d7cf1a1f866c46d1b8dfb70ac Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 06:27:20 +0000 Subject: [PATCH] fix(peer): reject empty peer names Co-Authored-By: Virgil --- node/peer.go | 3 --- node/peer_test.go | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/node/peer.go b/node/peer.go index 5054949..76f4ee3 100644 --- a/node/peer.go +++ b/node/peer.go @@ -75,9 +75,6 @@ func safeKeyPrefix(key string) string { // Peer names must be 1-64 characters, start and end with alphanumeric, // and contain only alphanumeric, hyphens, underscores, and spaces. func validatePeerName(name string) error { - if name == "" { - return nil // Empty names are allowed (optional field) - } if len(name) < PeerNameMinLength { return coreerr.E("validatePeerName", "peer name too short", nil) } diff --git a/node/peer_test.go b/node/peer_test.go index 7960f6f..393492b 100644 --- a/node/peer_test.go +++ b/node/peer_test.go @@ -543,7 +543,7 @@ func TestPeerRegistry_PeerNameValidation(t *testing.T) { peerName string shouldErr bool }{ - {"empty name allowed", "", false}, + {"empty name rejected", "", true}, {"single char", "A", false}, {"simple name", "MyPeer", false}, {"name with hyphen", "my-peer", false}, @@ -697,7 +697,7 @@ func TestValidatePeerName(t *testing.T) { peerName string shouldErr bool }{ - {"empty allowed", "", false}, + {"empty rejected", "", true}, {"single alphanumeric", "A", false}, {"simple alphanumeric", "TestPeer", false}, {"with hyphens", "test-peer", false},