AdguardTeam/AdGuardHome · warning

no valid parts

Error message

no valid parts

What it means

normalizeHostname lowercases the client-supplied hostname and splits it into parts consisting only of valid hostname runes (separating on '.' and invalid characters). If no valid parts remain, the entire hostname is invalid and the error is returned. This is a client-input validation error for DHCP hostname sanitization.

Source

Thrown at internal/dhcpd/v4_unix.go:92

func (s *v4Server) WriteDiskConfig6(c *V6ServerConf) {
}

// normalizeHostname normalizes a hostname sent by the client.  If err is not
// nil, norm is an empty string.
func normalizeHostname(hostname string) (norm string, err error) {
	defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }()

	if hostname == "" {
		return "", nil
	}

	norm = strings.ToLower(hostname)
	parts := strings.FieldsFunc(norm, func(c rune) (ok bool) {
		return c != '.' && !netutil.IsValidHostOuterRune(c)
	})

	if len(parts) == 0 {
		return "", fmt.Errorf("no valid parts")
	}

	norm = strings.Join(parts, "-")
	norm = strings.TrimSuffix(norm, "-")

	return norm, nil
}

// validHostnameForClient accepts the hostname sent by the client and its IP and
// returns either a normalized version of that hostname, or a new hostname
// generated from the IP address, or an empty string.
func (s *v4Server) validHostnameForClient(cliHostname string, ip netip.Addr) (hostname string) {
	hostname, err := normalizeHostname(cliHostname)
	if err != nil {
		log.Info("dhcpv4: %s", err)
	}

	if hostname == "" {

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Fix the client's hostname to contain valid DNS label characters (letters, digits, hyphen)
  2. If configuring a static lease, remove or correct the hostname field
  3. Reject/log the offending client MAC to identify the misbehaving device
  4. Treat as non-fatal for dynamic leases: log and fall back to serving the lease without a hostname

Example fix

// before
hostname := "***"

// after
hostname := "printer-1"
Defensive patterns

Strategy: validation

Validate before calling

func hasValidHostnameParts(h string) bool {
    norm := strings.ToLower(h)
    parts := strings.FieldsFunc(norm, func(c rune) bool {
        return c != '.' && !netutil.IsValidHostOuterRune(c)
    })
    return len(parts) > 0
}

Try / catch

if norm, err := normalizeHostname(h); err != nil {
    // serve lease without hostname rather than failing
    h = ""
} else { h = norm }

Prevention

When it happens

Trigger: A DHCP client sends a hostname composed entirely of invalid characters (e.g. "...", "***", non-ASCII garbage), so strings.FieldsFunc yields zero parts when AddStaticLease/validHostnameForClient normalizes it.

Common situations: IoT devices or misconfigured clients sending junk hostnames; malicious clients probing the DHCP server; static lease configuration with a hostname containing only punctuation.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/2950954bdd9cec45. Report an issue: GitHub.