{"record":{"id":"6f4b803a7a3211e1","repo":"micro/go-micro","slug":"fqdn-must-not-be-blank","errorCode":null,"errorMessage":"FQDN must not be blank","messagePattern":"FQDN must not be blank","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/mdns/zone.go","lineNumber":44,"sourceCode":"type MDNSService struct {\n\tInstance     string   // Instance name (e.g. \"hostService name\")\n\tService      string   // Service name (e.g. \"_http._tcp.\")\n\tDomain       string   // If blank, assumes \"local\"\n\tHostName     string   // Host machine DNS name (e.g. \"mymachine.net.\")\n\tserviceAddr  string   // Fully qualified service address\n\tinstanceAddr string   // Fully qualified instance address\n\tenumAddr     string   // _services._dns-sd._udp.<domain>\n\tIPs          []net.IP // IP addresses for the service's host\n\tTXT          []string // Service TXT records\n\tPort         int      // Service Port\n\tTTL          uint32\n}\n\n// validateFQDN returns an error if the passed string is not a fully qualified\n// hdomain name (more specifically, a hostname).\nfunc validateFQDN(s string) error {\n\tif len(s) == 0 {\n\t\treturn fmt.Errorf(\"FQDN must not be blank\")\n\t}\n\tif s[len(s)-1] != '.' {\n\t\treturn fmt.Errorf(\"FQDN must end in period: %s\", s)\n\t}\n\t// TODO(reddaly): Perform full validation.\n\n\treturn nil\n}\n\n// NewMDNSService returns a new instance of MDNSService.\n//\n// If domain, hostName, or ips is set to the zero value, then a default value\n// will be inferred from the operating system.\n//\n// TODO(reddaly): This interface may need to change to account for \"unique\n// record\" conflict rules of the mDNS protocol.  Upon startup, the server should\n// check to ensure that the instance name does not conflict with other instance\n// names, and, if required, select a new name.  There may also be conflicting","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/internal/util/mdns/zone.go#L26-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"Config files where the hostname field is present but empty; string slicing producing \"\"; a caller wrapping NewMDNSService that strips the default-filling behavior.","solutions":["Provide a non-empty hostName ending in a trailing dot, e.g. \"myhost.local.\"","Leave domain empty to get the default \"local.\" instead of an invalid value","If wrapping NewMDNSService, replicate its defaults (domain=\"local.\", hostName=os.Hostname()) before validation"],"exampleFix":"// before\nsvc, err := NewMDNSService(\"myapp\", \"_http._tcp\", \"\", \"\", 8080, ips, nil)\n// if a wrapper normalizes hostname to \"\"\n// after\nhost, _ := os.Hostname()\nsvc, err := NewMDNSService(\"myapp\", \"_http._tcp\", \"\", host+\".\", 8080, ips, nil)","handlingStrategy":"validation","validationCode":"func requireNonBlank(s, field string) string {\n\tif strings.TrimSpace(s) == \"\" {\n\t\tpanic(fmt.Sprintf(\"%s must not be blank before calling NewMDNSService\", field))\n\t}\n\treturn s\n}\n// hostName = requireNonBlank(hostName, \"hostName\")","typeGuard":"func isNonBlank(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"svc, err := NewMDNSService(instance, service, domain, hostName, port, ips, txt)\nif err != nil {\n\tif strings.Contains(err.Error(), \"must not be blank\") {\n\t\treturn fmt.Errorf(\"config error: hostname/domain is empty: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Require hostname/domain fields in config loading and fail fast on empty values","Only rely on empty-string defaults where the library provides them (domain defaults to \"local.\")","Trim and check user-supplied names before passing them in"],"tags":["validation","mdns","fqdn","input"],"backgroundTag":"blank-fqdn","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}