netbirdio/netbird · error

zone name exceeds maximum length of 255 characters

Error message

zone name exceeds maximum length of 255 characters

What it means

Zone.Validate() rejects names longer than 255 characters, measured in bytes (len(z.Name)), not runes. This bounds the human-readable zone name, separate from the DNS-compliant Domain field checked next.

Source

Thrown at management/internals/modules/zones/zone.go:73

func (z *Zone) FromAPIRequest(req *api.ZoneRequest) {
	z.Name = req.Name
	z.Domain = req.Domain
	z.EnableSearchDomain = req.EnableSearchDomain
	z.DistributionGroups = req.DistributionGroups

	enabled := true
	if req.Enabled != nil {
		enabled = *req.Enabled
	}
	z.Enabled = enabled
}

func (z *Zone) Validate() error {
	if z.Name == "" {
		return errors.New("zone name is required")
	}
	if len(z.Name) > 255 {
		return errors.New("zone name exceeds maximum length of 255 characters")
	}

	if !domain.IsValidDomainNoWildcard(z.Domain) {
		return errors.New("invalid zone domain format")
	}

	if len(z.DistributionGroups) == 0 {
		return errors.New("at least one distribution group is required")
	}

	return nil
}

func (z *Zone) EventMeta() map[string]any {
	return map[string]any{"name": z.Name, "domain": z.Domain}
}

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Shorten the zone name to at most 255 bytes.
  2. When generating names programmatically, truncate or hash components to a fixed budget.
  3. For unicode names, remember the limit is bytes: budget roughly 3-4 bytes per non-ASCII character.

Example fix

// before
name := strings.Repeat("corp-zone-", 30) // 300 bytes
// after
name := "corp-zone" // short, human-readable identifier
Defensive patterns

Strategy: validation

Validate before calling

if len(req.Name) > 255 {
    return fmt.Errorf("zone name must be at most 255 bytes, got %d", len(req.Name))
}

Try / catch

if err := zone.Validate(); err != nil {
    return respondBadRequest(err)
}

Prevention

When it happens

Trigger: A zone create/update whose name string exceeds 255 bytes; names built by concatenating generated identifiers without truncation; multi-byte (unicode) names whose rune count is under 255 but byte count is over.

Common situations: Template-generated names embedding long lists or UUIDs; copy-pasting a paragraph into the name field; unicode display names inflating the byte count.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/3a33f5afc8677f6b. Report an issue: GitHub.