{"record":{"id":"2d6daeb7032292d4","repo":"Tencent/WeKnora","slug":"sandbox-invalid-cube-dns-server-q-need-an-ip-ad","errorCode":null,"errorMessage":"sandbox: invalid cube DNS server %q (need an IP address)","messagePattern":"sandbox: invalid cube DNS server %q \\(need an IP address\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/cube_dns.go","lineNumber":25,"sourceCode":")\n\n// NormalizeCubeDNSServers trims, drops empties, rejects non-IP values, and\n// de-duplicates. Cube's template `dns` field is a list of nameserver IPs —\n// hostnames are not accepted. An empty result means \"leave Cubelet's default\".\nfunc NormalizeCubeDNSServers(raw []string) ([]string, error) {\n\tif len(raw) == 0 {\n\t\treturn nil, nil\n\t}\n\tout := make([]string, 0, len(raw))\n\tseen := make(map[string]struct{}, len(raw))\n\tfor _, item := range raw {\n\t\tip := strings.TrimSpace(item)\n\t\tif ip == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tparsed := net.ParseIP(ip)\n\t\tif parsed == nil {\n\t\t\treturn nil, fmt.Errorf(\"sandbox: invalid cube DNS server %q (need an IP address)\", item)\n\t\t}\n\t\tcanonical := parsed.String()\n\t\tif _, dup := seen[canonical]; dup {\n\t\t\tcontinue\n\t\t}\n\t\tseen[canonical] = struct{}{}\n\t\tout = append(out, canonical)\n\t}\n\tif len(out) == 0 {\n\t\treturn nil, nil\n\t}\n\treturn out, nil\n}\n","sourceCodeStart":7,"sourceCodeEnd":39,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/cube_dns.go#L7-L39","documentation":"NormalizeCubeDNSServers sanitizes the cube sandbox DNS server list: each entry must parse as an IP address via net.ParseIP. Non-IP strings (hostnames, malformed addresses) abort normalization with this error rather than being silently passed to the Cube SDK.","triggerScenarios":"Configuring cube DNS servers with a hostname like \"dns.internal\" or \"8.8.8.8/32\" or a typo'd IP (\"8.8.8.\"), then calling ResolveEffectiveConfig / SanitizeSandboxConfig / standardTemplateSpec, which invoke NormalizeCubeDNSServers.","commonSituations":"Putting a DNS hostname where an IP is required; copy-pasting CIDR notation into a server list; trailing dots or stray whitespace is trimmed but a wrong digit still fails; IPv6 entries must be literal addresses too.","solutions":["Replace each entry with a literal IP address, e.g. \"8.8.8.8\", \"1.1.1.1\", or an IPv6 literal like \"2001:4860:4860::8888\"","Run net.ParseIP on the value locally to confirm it parses before adding it to config","Remove CIDR suffixes and hostnames from the DNS server list — only bare IPs are valid","Empty and whitespace-only entries are skipped, not errors; check that the offending string has no hidden characters"],"exampleFix":"// before\nDNSServers: []string{\"dns.corp.internal\", \"8.8.8.8\"}\n// after\nDNSServers: []string{\"10.0.0.53\", \"8.8.8.8\"} // literal IPs only","handlingStrategy":"validation","validationCode":"for _, s := range cfg.Cube.DNSServers {\n    if net.ParseIP(strings.TrimSpace(s)) == nil {\n        return fmt.Errorf(\"DNS server %q is not a literal IP\", s)\n    }\n}","typeGuard":"func allDNSAreIPs(servers []string) bool {\n    for _, s := range servers {\n        if t := strings.TrimSpace(t := s); t != \"\" && net.ParseIP(t) == nil { return false }\n    }\n    return true\n}","tryCatchPattern":"servers, err := sandbox.NormalizeCubeDNSServers(raw)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid cube DNS server\") { /* drop/fix the offending entry */ }\n    return err\n}","preventionTips":["Configure DNS servers as literal IPs only — resolve hostnames yourself at config time","Strip CIDR notation (/24) and trailing dots before storing entries","Let NormalizeCubeDNSServers run at config load so duplicates are deduped and failures surface early"],"tags":["sandbox","dns","configuration","validation"],"backgroundTag":"invalid-ip-address","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}