{"record":{"id":"c07fbb6834a00710","repo":"kubernetes/kops","slug":"error-calculating-cidr-subnet-v","errorCode":null,"errorMessage":"error calculating CIDR subnet: %v","messagePattern":"error calculating CIDR subnet: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/subnet.go","lineNumber":570,"sourceCode":"func calculateSubnetCIDR(vpcCIDR, subnetCIDR *string) (*string, error) {\n\tif vpcCIDR == nil {\n\t\treturn nil, fmt.Errorf(\"expecting VPC CIDR to not be <nil>\")\n\t}\n\tif subnetCIDR == nil {\n\t\treturn nil, fmt.Errorf(\"expecting subnet CIDR to not be <nil>\")\n\t}\n\tif !strings.HasPrefix(aws.ToString(subnetCIDR), \"/\") {\n\t\treturn nil, fmt.Errorf(\"expecting subnet cidr to start with %q: %q\", \"/\", aws.ToString(subnetCIDR))\n\t}\n\n\tnewSize, netNum, err := utils.ParseCIDRNotation(aws.ToString(subnetCIDR))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing CIDR subnet: %v\", err)\n\t}\n\n\tnewCIDR, err := utils.CIDRSubnet(aws.ToString(vpcCIDR), newSize, netNum)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error calculating CIDR subnet: %v\", err)\n\t}\n\n\treturn aws.String(newCIDR), nil\n}\n","sourceCodeStart":552,"sourceCodeEnd":575,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/subnet.go#L552-L575","documentation":"utils.CalculateSubnetCIDR failed combining the parsed '/size,netnum' hint with the VPC CIDR — typically the netnum is outside the range addressable at the requested prefix size (e.g. netnum 300 for a /24 carve of the block).","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/awstasks/subnet.go:570 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pick a smaller netnum consistent with the prefix size","Or increase the prefix size so the netnum fits within the VPC block"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}