gastownhall/beads · error
peer name too long (max 64 characters)
Error message
peer name too long (max 64 characters)
What it means
ValidatePeerName enforces a maximum length of 64 characters for federation peer names because they are used as Dolt remote names. Names longer than 64 characters are rejected with this error. This also keeps remote names manageable in Dolt config output.
Source
Thrown at internal/storage/issueops/federation.go:22
"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, `
INSERT INTO federation_peers (name, remote_url, username, password_encrypted, sovereignty)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATEView on GitHub (pinned to 71377f2769)
Solutions
- Shorten the peer name to 64 characters or fewer (use a short label like "hq" or "replica-1").
- Keep the full address/URL in the peer's address field, not its name.
- Pre-validate name length in your config loader before calling AddFederationPeerInTx.
Example fix
// before peer := "https://dolt.example.com/very-long-org/very-long-repo-name" AddFederationPeerInTx(ctx, tx, peer, addr, nil) // after peer := "example-replica-1" // <= 64 chars, valid remote name AddFederationPeerInTx(ctx, tx, peer, addr, nil)
Defensive patterns
Strategy: validation
Validate before calling
if len(name) > 64 {
return fmt.Errorf("peer name %q exceeds 64 chars (len=%d)", name, len(name))
} Type guard
func validPeerName(name string) bool {
return len(name) > 0 && len(name) <= 64
} Try / catch
if err := ValidatePeerName(peer); err != nil {
return fmt.Errorf("peer %q rejected: %w (use a short label, keep URL in address)", peer, err)
} Prevention
- Use short labels (e.g. "hq", "replica-1") as peer names; store URLs in the address field.
- Enforce a length cap in your config loader mirroring the 64-char limit.
- Reject full URLs/hostnames at config parse time.
When it happens
Trigger: Calling ValidatePeerName or AddFederationPeerInTx with a name whose len(name) > 64 — e.g. a full URL, hostname with long path, or a generated UUID-prefixed identifier used verbatim as the peer name.
Common situations: Passing a full remote URL or org/repo path as the peer name instead of a short label; machine-generated names like "company-team-environment-region-replica-0001" exceeding the limit.
Related errors
- peer name cannot be empty
- 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/17ed58e7ec79b61b.
Report an issue: GitHub.