{"record":{"id":"1ef13e6bb0744da7","repo":"micro/go-micro","slug":"domain-q-is-not-a-fully-qualified-domain-name-v","errorCode":null,"errorMessage":"domain %q is not a fully-qualified domain name: %v","messagePattern":"domain %q is not a fully-qualified domain name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/util/mdns/zone.go","lineNumber":81,"sourceCode":"// hostName A/AAAA records.\nfunc NewMDNSService(instance, service, domain, hostName string, port int, ips []net.IP, txt []string) (*MDNSService, error) {\n\t// Sanity check inputs\n\tif instance == \"\" {\n\t\treturn nil, fmt.Errorf(\"missing service instance name\")\n\t}\n\tif service == \"\" {\n\t\treturn nil, fmt.Errorf(\"missing service name\")\n\t}\n\tif port == 0 {\n\t\treturn nil, fmt.Errorf(\"missing service port\")\n\t}\n\n\t// Set default domain\n\tif domain == \"\" {\n\t\tdomain = \"local.\"\n\t}\n\tif err := validateFQDN(domain); err != nil {\n\t\treturn nil, fmt.Errorf(\"domain %q is not a fully-qualified domain name: %v\", domain, err)\n\t}\n\n\t// Get host information if no host is specified.\n\tif hostName == \"\" {\n\t\tvar err error\n\t\thostName, err = os.Hostname()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"could not determine host: %v\", err)\n\t\t}\n\t\thostName = fmt.Sprintf(\"%s.\", hostName)\n\t}\n\tif err := validateFQDN(hostName); err != nil {\n\t\treturn nil, fmt.Errorf(\"hostName %q is not a fully-qualified domain name: %v\", hostName, err)\n\t}\n\n\tif len(ips) == 0 {\n\t\tvar err error\n\t\tips, err = net.LookupIP(trimDot(hostName))","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/internal/util/mdns/zone.go#L63-L99","documentation":"After defaulting an empty domain to \"local.\", NewMDNSService validates the domain with validateFQDN; if the domain is non-empty but not a valid FQDN (missing trailing dot), this wrapped error is returned, embedding the validation cause (%v).","triggerScenarios":"NewMDNSService(instance, service, \"local\", hostName, port, ips, txt) or any domain lacking the trailing period; also any validateFQDN failure like an empty domain string that wasn't defaulted.","commonSituations":"Configured search domains copied from resolv.conf without trailing dots; users writing \"mycompany.local\" in YAML/ENV config; case where the domain variable was reassigned after the defaulting branch.","solutions":["Append the trailing dot: domain = domain + \".\" before calling NewMDNSService","Use \"local.\" or leave domain empty so the default applies","Pre-validate with the same rule (non-empty, ends in '.') and normalize in config loading"],"exampleFix":"// before\nsvc, err := NewMDNSService(\"myapp\", \"_http._tcp\", \"mycompany.local\", \"\", 8080, ips, nil)\n// after\nsvc, err := NewMDNSService(\"myapp\", \"_http._tcp\", \"mycompany.local.\", \"\", 8080, ips, nil)","handlingStrategy":"validation","validationCode":"func normalizeDomain(d string) string {\n\tif d == \"\" { return \"local.\" }\n\tif !strings.HasSuffix(d, \".\") { return d + \".\" }\n\treturn d\n}\n// domain = normalizeDomain(cfg.Domain)","typeGuard":"func isValidDomain(d string) bool { return len(d) > 0 && d[len(d)-1] == '.' }","tryCatchPattern":"svc, err := NewMDNSService(instance, service, domain, hostName, port, ips, txt)\nif err != nil {\n\tif strings.Contains(err.Error(), \"is not a fully-qualified domain name\") {\n\t\treturn fmt.Errorf(\"fix the configured mDNS domain (must end in '.') : %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Normalize the domain once at config load, not at every call site","Prefer leaving domain empty to inherit the \"local.\" default","Strip whitespace and append the missing dot programmatically instead of relying on hand-edited config"],"tags":["validation","mdns","fqdn","dns"],"backgroundTag":"fqdn-missing-trailing-dot","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}