{"record":{"id":"ae8cd2ca561abfa9","repo":"kubernetes/kops","slug":"unexpected-ip-address-type-s","errorCode":null,"errorMessage":"unexpected IP address type: %s","messagePattern":"unexpected IP address type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/subnet/subnet.go","lineNumber":87,"sourceCode":"func SplitInto(additionalBits uint, parent *net.IPNet) ([]*net.IPNet, error) {\n\tnetworkLength, _ := parent.Mask.Size()\n\tnetworkLength += int(additionalBits)\n\n\tvar subnets []*net.IPNet\n\tfor i := 0; i < 1<<additionalBits; i++ {\n\t\tip4 := parent.IP.To4()\n\t\tif ip4 != nil {\n\t\t\tn := binary.BigEndian.Uint32(ip4)\n\t\t\tn += uint32(i) << uint(32-networkLength)\n\t\t\tsubnetIP := make(net.IP, len(ip4))\n\t\t\tbinary.BigEndian.PutUint32(subnetIP, n)\n\n\t\t\tsubnets = append(subnets, &net.IPNet{\n\t\t\t\tIP:   subnetIP,\n\t\t\t\tMask: net.CIDRMask(networkLength, 32),\n\t\t\t})\n\t\t} else {\n\t\t\treturn nil, fmt.Errorf(\"unexpected IP address type: %s\", parent)\n\t\t}\n\t}\n\n\treturn subnets, nil\n}\n","sourceCodeStart":69,"sourceCodeEnd":93,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/util/subnet/subnet.go#L69-L93","documentation":"subnet.SplitInto divides a parent CIDR into N equal child subnets. It supports IPv4 (4-byte) parents only; the IPv6 branch is not implemented, and any parent that is neither handled type triggers this error. Called via the SplitInto1/2/4/8 convenience wrappers.","triggerScenarios":"Calling SplitInto (or SplitInto2/4/8) with a parent net.IPNet whose IP is not a valid IPv4 address — e.g. an IPv6 CIDR like 2001:db8::/32, or an IPNet with a nil/zero-length IP.","commonSituations":"Dual-stack or IPv6 cluster configs passing IPv6 CIDRs into an IPv4-only helper, or a subnet CIDR built incorrectly (empty IP) from parsed input.","solutions":["Pass an IPv4 CIDR (net.ParseCIDR(\"10.0.0.0/16\")) to SplitInto","For IPv6 networks, implement/handle IPv6 subnetting separately instead of using SplitInto","Verify the parent IPNet was constructed correctly and its IP is To4()-convertible before calling"],"exampleFix":"// before\nparent, _ := net.ParseCIDR(\"2001:db8::/32\")\nsubnets, err := subnet.SplitInto4(parent) // IPv6 not supported\n// after\nparent, _ := net.ParseCIDR(\"10.0.0.0/16\")\nsubnets, err := subnet.SplitInto4(parent)","handlingStrategy":"validation","validationCode":"// Ensure parent is IPv4 before SplitInto\nif parent.IP.To4() == nil {\n\treturn fmt.Errorf(\"SplitInto requires IPv4, got %s\", parent)\n}","typeGuard":"func isIPv4Net(n *net.IPNet) bool {\n\treturn n != nil && n.IP.To4() != nil\n}","tryCatchPattern":null,"preventionTips":["Only pass IPv4 CIDRs into subnet.SplitInto/1/2/4/8","Handle IPv6 subnetting in separate code paths","Check IPNet construction so IP is never empty/zero-length"],"tags":["subnet","ipv4","ipv6"],"backgroundTag":"unsupported-address-family","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}