{"record":{"id":"31f22cc2ea26f85f","repo":"k3s-io/k3s","slug":"invalid-node-ip-w","errorCode":null,"errorMessage":"invalid node-ip: %w","messagePattern":"invalid node-ip: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/net.go","lineNumber":157,"sourceCode":"\tips := []net.IP{}\n\tif len(nodeIPs) == 0 {\n\t\thostIP, err := apinet.ChooseHostInterface()\n\t\tif err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t\tips = append(ips, hostIP)\n\t\t// If IPv6 it's an IPv6 only node\n\t\tif hostIP.To4() != nil {\n\t\t\thostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)\n\t\t\tif err == nil && !hostIPv6.Equal(hostIP) {\n\t\t\t\tips = append(ips, hostIPv6)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tvar err error\n\t\tips, err = ParseStringSliceToIPs(nodeIPs)\n\t\tif err != nil {\n\t\t\treturn \"\", nil, fmt.Errorf(\"invalid node-ip: %w\", err)\n\t\t}\n\t}\n\n\tif name == \"\" {\n\t\thostname, err := os.Hostname()\n\t\tif err != nil {\n\t\t\treturn \"\", nil, err\n\t\t}\n\t\tname = hostname\n\t}\n\n\t// Use lower case hostname to comply with kubernetes constraint:\n\t// https://github.com/kubernetes/kubernetes/issues/71140\n\tname = strings.ToLower(name)\n\n\treturn name, ips, nil\n}\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/util/net.go#L139-L175","documentation":"GetHostnameAndIPs(name, nodeIPs) parses the node IPs supplied via configuration (--node-ip style flags). When nodeIPs is non-empty it delegates to ParseStringSliceToIPs, which splits each element on commas and net.ParseIP's every token; the first unparseable token aborts with this wrapped 'invalid node-ip' error.","triggerScenarios":"Calling GetHostnameAndIPs with a node-ip list containing a malformed address ('10.0.0.256', '172.17.0', a hostname, a CIDR like '10.42.0.0/16') or an empty token produced by a trailing comma or ',,'.","commonSituations":"Config typos in CLI flags or cluster config files; trailing/double commas from templating or Helm values; users pasting DNS names or CIDRs where a literal IP is required.","solutions":["Check the exact node-ip list; every comma-separated token must be a literal IPv4/IPv6 address (no hostnames, no /prefix)","Remove trailing commas and empty items ('10.0.0.1,' to '10.0.0.1')","Validate at config-load time with util.ParseStringSliceToIPs (it is exported) before starting the node","Restart the agent/node after fixing so the config is re-read"],"exampleFix":"# before\n--node-ip=10.42.0.1,\n# after\n--node-ip=10.42.0.1","handlingStrategy":"validation","validationCode":"// Validate at config-load time, before GetHostnameAndIPs runs.\nif len(cfg.NodeIPs) > 0 {\n\tif _, err := util.ParseStringSliceToIPs(cfg.NodeIPs); err != nil {\n\t\treturn fmt.Errorf(\"bad --node-ip: %w\", err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"name, ips, err := util.GetHostnameAndIPs(cfg.NodeName, cfg.NodeIPs)\nif err != nil {\n\tif strings.Contains(err.Error(), \"invalid node-ip\") {\n\t\t// config problem, not environmental: fail fast with a clear message\n\t\treturn fmt.Errorf(\"fix --node-ip in config: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Treat node-ip as a strict IP list: validate with net.ParseIP before passing it on","Watch for trailing commas produced by templating ('10.0.0.1,')","Disallow hostnames and CIDRs in any field documented as node-ip","Add a config lint step that runs ParseStringSliceToIPs on startup"],"tags":["go","network","configuration","ip","k3s"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}