{"record":{"id":"4d3f23c499f0f0a1","repo":"kubernetes/kops","slug":"subnet-not-set-4d3f23","errorCode":null,"errorMessage":"subnet not set","messagePattern":"subnet not set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/awstasks/routetableassociation.go","lineNumber":123,"sourceCode":"\t\tif e.Subnet == nil {\n\t\t\treturn fi.RequiredField(\"Subnet\")\n\t\t}\n\t}\n\tif a != nil {\n\t\tif changes.RouteTable != nil {\n\t\t\treturn fi.CannotChangeField(\"RouteTable\")\n\t\t}\n\t\tif changes.Subnet != nil {\n\t\t\treturn fi.CannotChangeField(\"Subnet\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc findExistingRouteTableForSubnet(cloud awsup.AWSCloud, subnet *Subnet) (*ec2types.RouteTable, error) {\n\tctx := context.TODO()\n\tif subnet == nil {\n\t\treturn nil, fmt.Errorf(\"subnet not set\")\n\t}\n\tif subnet.ID == nil {\n\t\treturn nil, fmt.Errorf(\"subnet ID not set\")\n\t}\n\n\tsubnetID := fi.ValueOf(subnet.ID)\n\n\trequest := &ec2.DescribeRouteTablesInput{\n\t\tFilters: []ec2types.Filter{awsup.NewEC2Filter(\"association.subnet-id\", subnetID)},\n\t}\n\tresponse, err := cloud.EC2().DescribeRouteTables(ctx, request)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing RouteTables for subnet %q: %v\", subnetID, err)\n\t}\n\tif response == nil || len(response.RouteTables) == 0 {\n\t\treturn nil, nil\n\t}\n","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/awstasks/routetableassociation.go#L105-L141","documentation":"findExistingRouteTableForSubnet guards its input: if the *Subnet pointer is nil, there is no subnet to find a route table for, so it returns this error before making any AWS call. It is a programming/state invariant check, not an AWS failure.","triggerScenarios":"RenderAWS invokes findExistingRouteTableForSubnet with a nil Subnet — e.g. a RouteTableAssociation task whose Subnet field was never populated (spec missing subnet reference, or prior task rendering failed silently).","commonSituations":"Cluster spec with a subnet association referencing a nonexistent/removed subnet; bugs in spec deserialization; partially-applied manifests where the Subnet task did not resolve.","solutions":["Ensure the RouteTableAssociation's Subnet reference in the cluster spec points to a defined subnet","Run `kops get clusters --full` / inspect the manifest to verify subnet entries","Re-create the task state by re-running `kops update cluster` from a clean spec","If it occurs with a valid spec, file a kOps bug — a nil subnet reaching RenderAWS is an internal invariant failure"],"exampleFix":"// before (spec): association without subnet\nrouteTableAssociation: {}\n// after:\nrouteTableAssociation:\n  subnet: us-test-1a\n  routeTable: main","handlingStrategy":"validation","validationCode":"// validate spec before update\nfor _, a := range spec.RouteTableAssociations {\n  if a.Subnet == nil || a.Subnet.Name == \"\" { return fmt.Errorf(\"association %s missing subnet\", a.Name) }\n}","typeGuard":"func subnetIsSet(s *awstasks.Subnet) bool { return s != nil && s.ID != nil }","tryCatchPattern":"rt, err := findExistingRouteTableForSubnet(cloud, subnet)\nif err != nil && err.Error() == \"subnet not set\" {\n  return fmt.Errorf(\"task misconfigured: association has no Subnet reference\")\n}","preventionTips":["Always reference an existing subnet in route table associations","Validate manifests with `kops get --full` before `kops update`","Report nil-subnet occurrences with valid specs as kOps bugs"],"tags":["aws","routetableassociation","validation","bug"],"backgroundTag":"nil-required-resource","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"}