{"record":{"id":"399608d0482ea9e6","repo":"kubernetes/kops","slug":"server-group-task-for-instance-group-q-has-unexpe","errorCode":null,"errorMessage":"server group task for instance group %q has unexpected type %T","messagePattern":"server group task for instance group %q has unexpected type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions.go","lineNumber":1198,"sourceCode":"\t\tNodeConfigs: map[string]hcloudNodeConfig{},\n\t}\n\n\tfor _, ig := range tf.KopsModelContext.InstanceGroups {\n\t\tif !ig.Spec.Role.HasNode() {\n\t\t\tcontinue\n\t\t}\n\t\tif ig.Spec.Autoscale != nil && !fi.ValueOf(ig.Spec.Autoscale) {\n\t\t\tcontinue\n\t\t}\n\n\t\ttask, err := tf.Task(\"ServerGroup\", ig.Name)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"finding server group task for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tserverGroup, ok := task.(*hetznertasks.ServerGroup)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"server group task for instance group %q has unexpected type %T\", ig.Name, task)\n\t\t}\n\n\t\tnodeLabels, err := nodelabels.BuildNodeLabels(tf.Cluster, ig)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"building node labels for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tuserDataBytes, err := fi.ResourceAsBytes(serverGroup.UserData)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"reading user-data for instance group %q: %w\", ig.Name, err)\n\t\t}\n\n\t\tvar taints []corev1.Taint\n\t\tfor _, taintSpec := range ig.Spec.Taints {\n\t\t\tparsed, err := util.ParseTaint(taintSpec)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"parsing taints for instance group %q: %w\", ig.Name, err)\n\t\t\t}","sourceCodeStart":1180,"sourceCodeEnd":1216,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions.go#L1180-L1216","documentation":"After successfully fetching the ServerGroup task in HCloudClusterConfig, the code type-asserts it to *hetznertasks.ServerGroup. If the task stored under that name is a different type, the assertion fails and this error reports the actual Go type %T found.","triggerScenarios":"A task named ServerGroup/<ig.Name> exists in the context but was registered by different code/templates as another task type — e.g. custom/overridden Hetzner templates registering a different struct under the same task name.","commonSituations":"Customized model templates conflicting with built-in task names; running mixed kOps versions (binary newer than templates or vice versa); local forks renaming the task struct.","solutions":["Ensure the task registered as \"ServerGroup\" for the instance group is hetznertasks.ServerGroup (use stock Hetzner model templates).","Sync kOps binary and model/templates to the same version.","If forking, keep the task type and name consistent with HCloudClusterConfig's assertion."],"exampleFix":"// before (custom template)\ntask := &hetznertasks.ServerGroupVolume{Name:...}\n// after\ntask := &hetznertasks.ServerGroup{Name:...}","handlingStrategy":"type-guard","validationCode":"// Go: pre-check the registered task type before use\ntask, _ := tf.Task(\"ServerGroup\", ig.Name)\nif _, ok := task.(*hetznertasks.ServerGroup); !ok && task != nil {\n    return fmt.Errorf(\"ServerGroup/%s registered as unexpected %T\", ig.Name, task)\n}","typeGuard":"// Go\nfunc asServerGroup(t fi.Task) (*hetznertasks.ServerGroup, bool) {\n    sg, ok := t.(*hetznertasks.ServerGroup)\n    return sg, ok\n}","tryCatchPattern":null,"preventionTips":["Do not register custom tasks under the built-in \"ServerGroup\" name","Rebuild all templates when upgrading the hetznertasks package","Add CI check asserting task types for each cloud model"],"tags":["hetzner","type-assertion","template-function"],"backgroundTag":"unexpected-task-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"}