{"record":{"id":"20a7ae7de0049f70","repo":"cloudflare/cloudflared","slug":"erremptydomain","errorCode":"ErrEmptyDomain","errorMessage":"domain must not be empty","messagePattern":"domain must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"diagnostic/network/collector.go","lineNumber":11,"sourceCode":"package diagnostic\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"time\"\n)\n\nconst MicrosecondsFactor = 1000.0\n\nvar ErrEmptyDomain = errors.New(\"domain must not be empty\")\n\n// For now only support ICMP is provided.\ntype IPVersion int\n\nconst (\n\tV4 IPVersion = iota\n\tV6 IPVersion = iota\n)\n\ntype Hop struct {\n\tHop    uint8           `json:\"hop,omitempty\"`    // hop number along the route\n\tDomain string          `json:\"domain,omitempty\"` // domain and/or ip of the hop, this field will be '*' if the hop is a timeout\n\tRtts   []time.Duration `json:\"rtts,omitempty\"`   // RTT measurements in microseconds\n}\n\ntype TraceOptions struct {\n\tttl     uint64        // number of hops to perform\n\ttimeout time.Duration // wait timeout for each response","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/network/collector.go#L1-L29","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the input diagnostic data for rows missing a hostname field and filter or skip them before calling the collector","Skip empty domains upstream (e.g. continue on ErrEmptyDomain or pre-check with strings.TrimSpace(domain) == \"\")","Ensure the platform collector output format matches what the parser expects; update the parser if OS output format changed","Log the offending raw line to diagnose why domain extraction produced an empty value"],"exampleFix":"// before\ndomain, err := collector.DecodeLine(line)\nif err != nil {\n    return err\n}\n// after\ndomain, err := collector.DecodeLine(line)\nif errors.Is(err, network.ErrEmptyDomain) {\n    continue // skip rows with no hostname\n}\nif err != nil {\n    return err\n}","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(domain) == \"\" {\n    // skip or handle before calling the collector\n    return nil\n}","typeGuard":"func hasDomain(domain string) bool { return strings.TrimSpace(domain) != \"\" }","tryCatchPattern":"domain, err := collector.DecodeLine(line)\nif errors.Is(err, network.ErrEmptyDomain) {\n    continue // or log and skip\n} else if err != nil {\n    return fmt.Errorf(\"decode line: %w\", err)\n}","preventionTips":["Pre-filter diagnostic rows missing a hostname field","Trim and normalize fields before parsing","Log raw lines that fail domain extraction to spot OS output format changes"],"tags":["diagnostics","empty-field","parsing"],"backgroundTag":"empty-required-field","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}