gastownhall/beads · error
peer name cannot be empty
Error message
peer name cannot be empty
What it means
ValidatePeerName checks that a federation peer name is safe to use as a Dolt remote name. An empty name is rejected immediately with this plain error. Peer names become remote identifiers, so they must be non-empty, unique-safe strings.
Source
Thrown at internal/storage/issueops/federation.go:19
package issueops
import (
"context"
"database/sql"
"fmt"
"regexp"
"strings"
"github.com/steveyegge/beads/internal/storage"
)
// validPeerNameRegex matches valid peer names (alphanumeric, hyphens, underscores).
var validPeerNameRegex = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_-]*$`)
// ValidatePeerName checks that a peer name is safe for use as a Dolt remote name.
func ValidatePeerName(name string) error {
if name == "" {
return fmt.Errorf("peer name cannot be empty")
}
if len(name) > 64 {
return fmt.Errorf("peer name too long (max 64 characters)")
}
if !validPeerNameRegex.MatchString(name) {
return fmt.Errorf("peer name must start with a letter and contain only alphanumeric characters, hyphens, and underscores")
}
return nil
}
// AddFederationPeerInTx upserts a federation peer record. The encryptedPwd
// should already be encrypted by the caller; pass nil for no password.
func AddFederationPeerInTx(ctx context.Context, tx *sql.Tx, peer *storage.FederationPeer, encryptedPwd []byte) error {
if err := ValidatePeerName(peer.Name); err != nil {
return fmt.Errorf("invalid peer name: %w", err)
}
_, err := tx.ExecContext(ctx, `View on GitHub (pinned to 71377f2769)
Solutions
- Provide a non-empty peer name when adding the federation peer (e.g. --peer alpha).
- Check your config/env for the peer-name variable and set it.
- Call ValidatePeerName in your setup code before AddFederationPeerInTx to fail with a clear message.
Example fix
// before
AddFederationPeerInTx(ctx, tx, cfg.PeerName, addr, nil) // PeerName may be ""
// after
if cfg.PeerName == "" {
return fmt.Errorf("--peer is required for federation setup")
}
AddFederationPeerInTx(ctx, tx, cfg.PeerName, addr, nil) Defensive patterns
Strategy: validation
Validate before calling
if err := issueops.ValidatePeerName(name); err != nil {
return fmt.Errorf("invalid peer name %q: %w", name, err)
} Type guard
func validPeerName(name string) bool {
return name != "" && len(name) <= 64 && issueopsPeerNameRe.MatchString(name) // ^[a-zA-Z][a-zA-Z0-9_-]*$
} Try / catch
if err := ValidatePeerName(cfg.PeerName); err != nil {
return fmt.Errorf("federation config: %w", err)
} Prevention
- Require --peer in federation commands instead of defaulting to empty.
- Check config/env for empty peer-name values at startup.
- Call ValidatePeerName during config validation, before any database work.
When it happens
Trigger: Calling ValidatePeerName or AddFederationPeerInTx with name == "" — e.g. an unset --peer flag, empty config value, or a peer record loaded from storage with a blank name.
Common situations: Config file with `peer: ""`; environment variable for the peer name not set; constructing federation setup from templated config where the placeholder was never substituted.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- peer name too long (max 64 characters)
- peer name cannot be empty
- peer name too long (max 64 characters)
- peer name must start with a letter and contain only alphanum
- peer name must start with a letter and contain only alphanum
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/6dd038edff375dc4.
Report an issue: GitHub.