cloudflare/cloudflared · warning

ErrEmptyDomain

ErrEmptyDomain

Error message

domain must not be empty

What it means

ErrEmptyDomain is a sentinel error returned by network diagnostic collectors (DecodeLine and platform-specific collector implementations) when a parsed hostname/domain field is empty. The collectors parse system network diagnostic output line-by-line and require a non-empty domain to proceed; when trimming or extraction yields an empty string, this error is returned instead of a nil result.

Source

Thrown at diagnostic/network/collector.go:11

package diagnostic

import (
	"context"
	"errors"
	"time"
)

const MicrosecondsFactor = 1000.0

var ErrEmptyDomain = errors.New("domain must not be empty")

// For now only support ICMP is provided.
type IPVersion int

const (
	V4 IPVersion = iota
	V6 IPVersion = iota
)

type Hop struct {
	Hop    uint8           `json:"hop,omitempty"`    // hop number along the route
	Domain string          `json:"domain,omitempty"` // domain and/or ip of the hop, this field will be '*' if the hop is a timeout
	Rtts   []time.Duration `json:"rtts,omitempty"`   // RTT measurements in microseconds
}

type TraceOptions struct {
	ttl     uint64        // number of hops to perform
	timeout time.Duration // wait timeout for each response

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Check the input diagnostic data for rows missing a hostname field and filter or skip them before calling the collector
  2. Skip empty domains upstream (e.g. continue on ErrEmptyDomain or pre-check with strings.TrimSpace(domain) == "")
  3. Ensure the platform collector output format matches what the parser expects; update the parser if OS output format changed
  4. Log the offending raw line to diagnose why domain extraction produced an empty value

Example fix

// before
domain, err := collector.DecodeLine(line)
if err != nil {
    return err
}
// after
domain, err := collector.DecodeLine(line)
if errors.Is(err, network.ErrEmptyDomain) {
    continue // skip rows with no hostname
}
if err != nil {
    return err
}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(domain) == "" {
    // skip or handle before calling the collector
    return nil
}

Type guard

func hasDomain(domain string) bool { return strings.TrimSpace(domain) != "" }

Try / catch

domain, err := collector.DecodeLine(line)
if errors.Is(err, network.ErrEmptyDomain) {
    continue // or log and skip
} else if err != nil {
    return fmt.Errorf("decode line: %w", err)
}

Prevention

When it happens

Trigger: Calling diagnostic/network collector functions such as DecodeLine when the underlying platform output (collector_unix.go:74, collector_windows.go:77) yields a domain string that is empty after suffix trimming/normalization — e.g. a blank or malformed line in the diagnostic data with no hostname field.

Common situations: Running network diagnostics on hosts where the OS output contains rows with no hostname (e.g. rows for numeric-only entries or blank traceroute hops); parsing truncated diagnostic output; locale/format changes in OS tools causing the domain extraction regex/cut to fail silently.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/20a7ae7de0049f70. Report an issue: GitHub.