{"record":{"id":"a754eeae2a50881e","repo":"kubernetes/kops","slug":"unhandled-loadbalancer-type-q","errorCode":null,"errorMessage":"unhandled LoadBalancer type %q","messagePattern":"unhandled LoadBalancer type %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/awsmodel/api_loadbalancer.go","lineNumber":61,"sourceCode":"// Build is responsible for building the KubeAPI tasks for the aws model\nfunc (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error {\n\t// Configuration where an ELB fronts the API\n\tif !b.UseLoadBalancerForAPI() {\n\t\treturn nil\n\t}\n\n\tlbSpec := b.Cluster.Spec.API.LoadBalancer\n\tif lbSpec == nil {\n\t\t// Skipping API ELB creation; not requested in Spec\n\t\treturn nil\n\t}\n\n\tswitch lbSpec.Type {\n\tcase kops.LoadBalancerTypeInternal, kops.LoadBalancerTypePublic:\n\t// OK\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unhandled LoadBalancer type %q\", lbSpec.Type)\n\t}\n\n\tvar nlbSubnetMappings []*awstasks.SubnetMapping\n\tif len(lbSpec.Subnets) != 0 {\n\t\t// Subnets have been explicitly set\n\t\tfor _, subnet := range lbSpec.Subnets {\n\t\t\tfor _, clusterSubnet := range b.Cluster.Spec.Networking.Subnets {\n\t\t\t\tif subnet.Name == clusterSubnet.Name {\n\t\t\t\t\tnlbSubnetMapping := &awstasks.SubnetMapping{\n\t\t\t\t\t\tSubnet: b.LinkToSubnet(&clusterSubnet),\n\t\t\t\t\t}\n\t\t\t\t\tif subnet.PrivateIPv4Address != nil {\n\t\t\t\t\t\tnlbSubnetMapping.PrivateIPv4Address = subnet.PrivateIPv4Address\n\t\t\t\t\t}\n\t\t\t\t\tif subnet.AllocationID != nil {\n\t\t\t\t\t\tnlbSubnetMapping.AllocationID = subnet.AllocationID\n\t\t\t\t\t}\n\t\t\t\t\tnlbSubnetMappings = append(nlbSubnetMappings, nlbSubnetMapping)","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/awsmodel/api_loadbalancer.go#L43-L79","documentation":"APILoadBalancerBuilder.Build in pkg/model/awsmodel builds the AWS load balancer task for the kOps API endpoint. The cluster spec's api.loadBalancer.type is only allowed to be \"Internal\" or \"Public\"; any other string makes the builder fail fast with this error rather than silently provisioning the wrong LB type.","triggerScenarios":"Running `kops update cluster` when cluster spec has api.loadBalancer.type set to a value other than Internal/Public (typo like \"internal \" (trailing space), \"private\", \"external\", or mixed case like \"PUBLIC\").","commonSituations":"Hand-edited cluster.yaml after upgrade, snippets copied from docs for other clouds, or specs written before validation for this field existed.","solutions":["Set api.loadBalancer.type to exactly \"Internal\" or \"Public\" in the cluster spec","Run `kops set cluster` / `kops edit cluster` instead of hand-editing to avoid typos","Trim whitespace and match case exactly, then `kops update cluster` again"],"exampleFix":"# before\napi:\n  loadBalancer:\n    type: private\n# after\napi:\n  loadBalancer:\n    type: Internal","handlingStrategy":"validation","validationCode":"lb := cluster.Spec.API.LoadBalancer\nif lb != nil && lb.Type != kops.LoadBalancerTypeInternal && lb.Type != kops.LoadBalancerTypePublic {\n    return fmt.Errorf(\"api.loadBalancer.type must be Internal or Public, got %q\", lb.Type)\n}","typeGuard":"func validLBType(t string) bool {\n    return t == kops.LoadBalancerTypeInternal || t == kops.LoadBalancerTypePublic\n}","tryCatchPattern":"if err := kopsUpdateCluster(cluster); err != nil {\n    if strings.Contains(err.Error(), \"unhandled LoadBalancer type\") {\n        // fix spec.api.loadBalancer.type and retry\n    }\n    return err\n}","preventionTips":["Only use the documented values Internal and Public for api.loadBalancer.type","Edit the cluster via `kops edit cluster` to get spec validation","Trim whitespace and match capitalization exactly"],"tags":["aws","kops","loadbalancer","cluster-spec"],"backgroundTag":"invalid-loadbalancer-type","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"}