micro/go-micro · error

FQDN must not be blank

Error message

FQDN must not be blank

What it means

validateFQDN rejects an empty string because a fully-qualified domain name must contain at least one label and end in a period. NewMDNSService calls it on domain and hostName inputs, so an empty string passed for either reaches this error. It is a pure input-validation guard.

Source

Thrown at internal/util/mdns/zone.go:44

type MDNSService struct {
	Instance     string   // Instance name (e.g. "hostService name")
	Service      string   // Service name (e.g. "_http._tcp.")
	Domain       string   // If blank, assumes "local"
	HostName     string   // Host machine DNS name (e.g. "mymachine.net.")
	serviceAddr  string   // Fully qualified service address
	instanceAddr string   // Fully qualified instance address
	enumAddr     string   // _services._dns-sd._udp.<domain>
	IPs          []net.IP // IP addresses for the service's host
	TXT          []string // Service TXT records
	Port         int      // Service Port
	TTL          uint32
}

// validateFQDN returns an error if the passed string is not a fully qualified
// hdomain name (more specifically, a hostname).
func validateFQDN(s string) error {
	if len(s) == 0 {
		return fmt.Errorf("FQDN must not be blank")
	}
	if s[len(s)-1] != '.' {
		return fmt.Errorf("FQDN must end in period: %s", s)
	}
	// TODO(reddaly): Perform full validation.

	return nil
}

// NewMDNSService returns a new instance of MDNSService.
//
// If domain, hostName, or ips is set to the zero value, then a default value
// will be inferred from the operating system.
//
// TODO(reddaly): This interface may need to change to account for "unique
// record" conflict rules of the mDNS protocol.  Upon startup, the server should
// check to ensure that the instance name does not conflict with other instance
// names, and, if required, select a new name.  There may also be conflicting

View on GitHub (pinned to 24529f1404)

Solutions

  1. Provide a non-empty hostName ending in a trailing dot, e.g. "myhost.local."
  2. Leave domain empty to get the default "local." instead of an invalid value
  3. If wrapping NewMDNSService, replicate its defaults (domain="local.", hostName=os.Hostname()) before validation

Example fix

// before
svc, err := NewMDNSService("myapp", "_http._tcp", "", "", 8080, ips, nil)
// if a wrapper normalizes hostname to ""
// after
host, _ := os.Hostname()
svc, err := NewMDNSService("myapp", "_http._tcp", "", host+".", 8080, ips, nil)
Defensive patterns

Strategy: validation

Validate before calling

func requireNonBlank(s, field string) string {
	if strings.TrimSpace(s) == "" {
		panic(fmt.Sprintf("%s must not be blank before calling NewMDNSService", field))
	}
	return s
}
// hostName = requireNonBlank(hostName, "hostName")

Type guard

func isNonBlank(s string) bool { return strings.TrimSpace(s) != "" }

Try / catch

svc, err := NewMDNSService(instance, service, domain, hostName, port, ips, txt)
if err != nil {
	if strings.Contains(err.Error(), "must not be blank") {
		return fmt.Errorf("config error: hostname/domain is empty: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling NewMDNSService(instance, service, domain, hostName, ...) with domain == "" is fine (it defaults to "local."), but hostName == "" only triggers OS hostname lookup; this specific error fires when an explicitly constructed empty value bypasses defaults — e.g. calling validateFQDN directly with "" or passing a whitespace-trimmed-to-empty string.

Common situations: Config files where the hostname field is present but empty; string slicing producing ""; a caller wrapping NewMDNSService that strips the default-filling behavior.

Related errors


AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01). Data as JSON: /api/errors/6f4b803a7a3211e1. Report an issue: GitHub.