fix(peer): reject empty peer names
Some checks failed
Security Scan / security (push) Successful in 12s
Test / test (push) Failing after 46s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 06:27:20 +00:00
parent ee623a7343
commit 572970d255
2 changed files with 2 additions and 5 deletions

View file

@ -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)
}

View file

@ -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},