{"record":{"id":"b664f04d7e116391","repo":"kubernetes/kops","slug":"unexpected-ip-address-type-for-serviceclusteripran","errorCode":null,"errorMessage":"unexpected IP address type for ServiceClusterIPRange: %s","messagePattern":"unexpected IP address type for ServiceClusterIPRange: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/context.go","lineNumber":133,"sourceCode":"\t\tbinary.BigEndian.PutUint32(serviceIP, n)\n\t\treturn serviceIP, nil\n\t}\n\n\tip6 := cidr.IP.To16()\n\tif ip6 != nil {\n\t\tbaseIPInt := big.NewInt(0)\n\t\tbaseIPInt.SetBytes(ip6)\n\t\tserviceIPInt := big.NewInt(0)\n\t\tserviceIPInt.Add(big.NewInt(int64(id)), baseIPInt)\n\t\tserviceIP := make(net.IP, len(ip6))\n\t\tserviceIPBytes := serviceIPInt.Bytes()\n\t\tfor i := range serviceIPBytes {\n\t\t\tserviceIP[len(serviceIP)-len(serviceIPBytes)+i] = serviceIPBytes[i]\n\t\t}\n\t\treturn serviceIP, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"unexpected IP address type for ServiceClusterIPRange: %s\", networkingSpec.ServiceClusterIPRange)\n}\n\n// Image returns the docker image name for the specified component\nfunc Image(component string, clusterSpec *kops.ClusterSpec, assetsBuilder *assets.AssetBuilder) (string, error) {\n\tif assetsBuilder == nil {\n\t\treturn \"\", fmt.Errorf(\"unable to parse assets as assetBuilder is not defined\")\n\t}\n\n\tkubernetesVersion, err := kopsmodel.ParseKubernetesVersion(clusterSpec.KubernetesVersion)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\timageName := component\n\n\tif !kubernetesVersion.IsBaseURL() {\n\t\timage := \"registry.k8s.io/\" + imageName + \":\" + \"v\" + kubernetesVersion.String()\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/context.go#L115-L151","documentation":"WellKnownServiceIP supports deriving the well-known IP for IPv4 and IPv6 service CIDRs. If the parsed CIDR's IP is neither a 4-byte nor a 16-byte address (or the computed IP bytes cannot be represented), the function reaches its terminal return and errors that the IP address type is unexpected.","triggerScenarios":"ServiceClusterIPRange parses as a CIDR but its base address is not a standard IPv4/IPv6 length — e.g. a 4-in-6 mapped address handling edge case, or an unusually formed CIDR string accepted by ParseCIDR but unsupported downstream.","commonSituations":"Experimental CIDR values in custom manifests; dual-stack strings accidentally combined (e.g. containing both families); scripts generating CIDRs from non-IP data.","solutions":["Use a standard IPv4 (e.g. 100.64.0.0/13) or IPv6 (e.g. fd00:5:64::/108) service CIDR","Inspect cluster.spec.networking.serviceClusterIPRange for stray characters or dual-stack concatenation","Regenerate the manifest with `kops create cluster` defaults instead of hand-editing the field"],"exampleFix":"# before\nserviceClusterIPRange: 100.64.0.0/13,fd00:5:64::/108\n# after (set families separately for dual-stack)\nserviceClusterIPRange: 100.64.0.0/13","handlingStrategy":"validation","validationCode":"func isSupportedServiceCIDR(s string) bool {\n\t_, cidr, err := net.ParseCIDR(s)\n\tif err != nil { return false }\n\treturn cidr.IP.To4() != nil || len(cidr.IP) == net.IPv6len\n}","typeGuard":"func isIPv4OrIPv6CIDR(s string) bool {\n\t_, cidr, err := net.ParseCIDR(s)\n\treturn err == nil && (cidr.IP.To4() != nil || len(cidr.IP) == net.IPv6len)\n}","tryCatchPattern":"ip, err := WellKnownServiceIP(networkingSpec, id)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unexpected IP address type\") {\n\t\t// replace CIDR with standard IPv4/IPv6 and retry\n\t}\n\treturn err\n}","preventionTips":["Use only standard IPv4 or IPv6 CIDRs for serviceClusterIPRange","For dual-stack, configure families via the dedicated dual-stack fields, not comma-joined CIDRs","Avoid programmatically composing CIDR strings from non-IP input data"],"tags":["networking","ipv6","cidr"],"backgroundTag":"unsupported-ip-family","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}