{"record":{"id":"ed59915cd840837c","repo":"kubernetes/kops","slug":"error-parsing-cidr-q-v","errorCode":null,"errorMessage":"error parsing CIDR %q: %v","messagePattern":"error parsing CIDR %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/subnet/cidrmap.go","lineNumber":84,"sourceCode":"\t\t\t\tnewHigh++\n\t\t\t}\n\t\t}\n\t\tbinary.BigEndian.PutUint64(ip[0:8], newHigh)\n\t\tbinary.BigEndian.PutUint64(ip[8:16], newLow)\n\t}\n\treturn nil\n}\n\nfunc duplicateIP(src net.IP) net.IP {\n\tret := make(net.IP, len(src))\n\tcopy(ret, src)\n\treturn ret\n}\n\nfunc (c *CIDRMap) Allocate(from string, mask net.IPMask) (*net.IPNet, error) {\n\t_, cidr, err := net.ParseCIDR(from)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing CIDR %q: %v\", from, err)\n\t}\n\n\tvar candidate net.IPNet\n\tcandidate.Mask = mask\n\tcandidate.IP = duplicateIP(cidr.IP)\n\n\tfor {\n\t\t// Note we increment first, so we won't ever use the first range (e.g. 10.0.0.0/n)\n\t\tif err := incrementIP(candidate.IP, mask); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Check we're still in the range we're drawing from\n\t\tif !cidrsOverlap(cidr, &candidate) {\n\t\t\tklog.Infof(\"candidate CIDR %v is not in CIDR %v\", candidate, cidr)\n\t\t\tbreak\n\t\t}\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/util/subnet/cidrmap.go#L66-L102","documentation":"CIDRMap.Allocate carves subnets out of a parent range given as a CIDR string. The `from` argument must parse via net.ParseCIDR; if it doesn't, allocation cannot start and this error quotes the invalid range. Like MarkInUse it validates the same input class but under the Allocate entry point.","triggerScenarios":"Calling Allocate with a malformed `from` base CIDR — e.g. \"10.0.0.0\" without /mask, an out-of-range prefix like /33, or IPv6 text where IPv4 is expected — typically from subnet/cidr allocation during cluster creation.","commonSituations":"Cluster spec with a bad nonMasqueradeCIDR or subnet base range, typo'd YAML values, or programmatically built CIDR strings that were never validated.","solutions":["Correct the base CIDR string to valid notation (e.g. 10.0.0.0/16) and retry","Validate the value before calling Allocate (net.ParseCIDR in a pre-check)","Fix the cluster spec field supplying this value (kops edit cluster) and update the cluster"],"exampleFix":"// before\nsubnet, err := cidrMap.Allocate(\"10.0.0.0/33\", mask)\n// after\nsubnet, err := cidrMap.Allocate(\"10.0.0.0/16\", mask)","handlingStrategy":"validation","validationCode":"if _, _, err := net.ParseCIDR(from); err != nil {\n\treturn nil, fmt.Errorf(\"base CIDR %q invalid: %w\", from, err)\n}","typeGuard":"func isCIDR(s string) bool {\n\t_, _, err := net.ParseCIDR(s)\n\treturn err == nil\n}","tryCatchPattern":null,"preventionTips":["Validate the parent/base CIDR string before allocation","Sanitize YAML-sourced CIDR values (strip whitespace/quotes)","Verify IPv4 vs IPv6 expectations for the field feeding this value"],"tags":["cidr","network","validation"],"backgroundTag":"invalid-cidr-notation","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"}