{"record":{"id":"e77c893ed79b059d","repo":"kubernetes/kops","slug":"instancegroup-cannot-be-nil","errorCode":null,"errorMessage":"instanceGroup cannot be nil","messagePattern":"instanceGroup cannot be nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodemodel/nodeupconfigbuilder.go","lineNumber":180,"sourceCode":"\tconfigBuilder := nodeUpConfigBuilder{\n\t\tassetBuilder:               assetBuilder,\n\t\tchannelsManifest:           channelsManifest,\n\t\tconfigBase:                 configBase,\n\t\tcluster:                    cluster,\n\t\tetcdManifests:              etcdManifests,\n\t\timages:                     images,\n\t\tencryptionConfigSecretHash: encryptionConfigSecretHash,\n\t}\n\n\treturn &configBuilder, nil\n}\n\n// BuildConfig returns the NodeUp config and auxiliary config.\nfunc (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddresses model.WellKnownAddresses, keysets map[string]*fi.Keyset) (*nodeup.Config, *nodeup.BootConfig, error) {\n\tcluster := n.cluster\n\n\tif ig == nil {\n\t\treturn nil, nil, fmt.Errorf(\"instanceGroup cannot be nil\")\n\t}\n\n\trole := ig.Spec.Role\n\tif role == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"cannot determine role for instance group: %v\", ig.ObjectMeta.Name)\n\t}\n\n\tisMaster := role.HasControlPlane()\n\thasAPIServer := isMaster || role.HasAPIServer()\n\n\tconfig, bootConfig := nodeup.NewConfig(cluster, ig)\n\n\tigModel, err := kopsmodel.ForInstanceGroup(cluster, ig)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"building instance group model: %w\", err)\n\t}\n\n\tif !hasAPIServer && n.assetBuilder.KubeletSupportedVersion != \"\" {","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodemodel/nodeupconfigbuilder.go#L162-L198","documentation":"BuildConfig requires a non-nil InstanceGroup to generate the NodeUp config. Passing nil means the caller lost track of which instance group the node belongs to, so role-specific config (control-plane vs node) cannot be produced.","triggerScenarios":"BuildConfig called with ig == nil, e.g. when nodeup model building fails to map a node/instance to its InstanceGroup before building config.","commonSituations":"Node not associated with any instance group; a nil IG passed from the nodeup bootstrap path due to lookup failure; programmatic callers of BuildConfig with uninitialized variable.","solutions":["Ensure the InstanceGroup is resolved for the node before calling BuildConfig","Check that the node's InstanceGroup lookup (by node labels/name) succeeds — an unmatched node usually indicates the IG was deleted or renamed","Pass the correct *kops.InstanceGroup from the caller (e.g. from nodeup bootstrap data) instead of nil"],"exampleFix":"// before\nconfig, _, err := builder.BuildConfig(nil, addresses, keysets)\n// after\nig, err := findInstanceGroup(nodeName)\nif err != nil { return err }\nconfig, _, err := builder.BuildConfig(ig, addresses, keysets)","handlingStrategy":"validation","validationCode":"if ig == nil {\n    return fmt.Errorf(\"refusing BuildConfig: instance group unresolved for node\")\n}","typeGuard":"func igResolved(ig *kops.InstanceGroup) bool { return ig != nil }","tryCatchPattern":null,"preventionTips":["Resolve the InstanceGroup (labels/name lookup) before building nodeup config","Fail fast upstream when IG lookup returns nil instead of passing it through","Keep IG deletion/renames coordinated with node bootstrapping"],"tags":["instancegroup","nodeup","nil-check"],"backgroundTag":"nil-instance-group","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"}