{"record":{"id":"42f4a66afba96ee7","repo":"vitessio/vitess","slug":"err-42f4a6","errorCode":null,"errorMessage":"err","messagePattern":"err","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/netutil/netutil.go","lineNumber":104,"sourceCode":"\tif len(resolvedHostnames) == 0 {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: reverse lookup of this machine's local IP (%v) did not return any hostnames\", localIP)\n\t}\n\t// If multiple hostnames are found, we return only the first one.\n\t// If multiple hostnames are listed e.g. in an entry in the /etc/hosts file,\n\t// the current Go implementation returns them in that order.\n\t// Example for an /etc/hosts entry:\n\t//   127.0.0.1\tlocalhost.localdomain localhost\n\t// If the FQDN isn't returned by this function, check the order in the entry\n\t// in your /etc/hosts file.\n\treturn strings.TrimSuffix(resolvedHostnames[0], \".\"), nil\n}\n\n// FullyQualifiedHostnameOrPanic is the same as FullyQualifiedHostname\n// but panics in case of an error.\nfunc FullyQualifiedHostnameOrPanic() string {\n\thostname, err := FullyQualifiedHostname()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn hostname\n}\n\nfunc dnsLookup(host string) ([]net.IP, error) {\n\taddrs, err := net.LookupHost(host)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error looking up dns name [%v]: (%v)\", host, err)\n\t}\n\tnaddr := make([]net.IP, len(addrs))\n\tfor i, a := range addrs {\n\t\tnaddr[i] = net.ParseIP(a)\n\t}\n\tsort.Slice(naddr, func(i, j int) bool {\n\t\treturn bytes.Compare(naddr[i], naddr[j]) < 0\n\t})\n\treturn naddr, nil\n}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/netutil/netutil.go#L86-L122","documentation":"FullyQualifiedHostnameOrPanic wraps FullyQualifiedHostname, which resolves the local hostname to a fully qualified domain name via DNS (net.LookupHost). It panics with the raw error when resolution fails — typically no network/DNS availability or the hostname not resolving back to an address. It is meant for startup paths where a hostname is mandatory.","triggerScenarios":"Calling FullyQualifiedHostnameOrPanic (directly or via MakeZkConfigFromString, StartLocalZk) on a machine whose hostname is not in /etc/hosts, has no DNS record, or in a container/sandbox with no network; also transient DNS lookup failures.","commonSituations":"Running vitess tools (zkctl, vtctld local setup) in minimal Docker containers or Kubernetes pods where the pod hostname isn't resolvable; offline CI environments; misconfigured /etc/hosts.","solutions":["Fix the environment: ensure `hostname -f` works — add the machine's hostname to /etc/hosts (e.g. '127.0.0.1 myhost.mydomain myhost') or configure DNS.","Use FullyQualifiedHostname() and handle the error instead of the OrPanic variant in non-critical paths.","Set an explicit hostname via the tool's config flag rather than auto-detection.","Retry on transient DNS failures if the environment is known-good."],"exampleFix":"// before\nhost := netutil.FullyQualifiedHostnameOrPanic() // panics without DNS\n// after\nhost, err := netutil.FullyQualifiedHostname()\nif err != nil {\n    log.Warn(\"FQDN lookup failed, falling back to short hostname\", slog.Any(\"error\", err))\n    host, _ = os.Hostname()\n}","handlingStrategy":"fallback","validationCode":"if _, err := net.LookupHost(hostname()); err != nil {\n    log.Warn(\"hostname not resolvable; fix /etc/hosts or DNS before startup\")\n}","typeGuard":null,"tryCatchPattern":"// prefer the error-returning variant:\nhost, err := netutil.FullyQualifiedHostname()\nif err != nil {\n    host, _ = os.Hostname() // fallback\n}","preventionTips":["Ensure `hostname -f` resolves in every deployment environment (add /etc/hosts entries in container images).","Use FullyQualifiedHostname() instead of the OrPanic variant outside mandatory startup paths.","Provide an explicit hostname flag for environments without DNS."],"tags":["network","dns","hostname","panic"],"backgroundTag":"hostname-resolution-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}