{"record":{"id":"bdc485968f406014","repo":"kubernetes/kops","slug":"instancegroup-name-is-missing","errorCode":null,"errorMessage":"InstanceGroup name is missing","messagePattern":"InstanceGroup name is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/toolbox_enroll.go","lineNumber":552,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building full cluster spec: %w\", err)\n\t}\n\tb.fullCluster = fullCluster\n\treturn fullCluster, nil\n}\n\nfunc (b *ConfigBuilder) GetInstanceGroup(ctx context.Context) (*kops.InstanceGroup, error) {\n\tif b.InstanceGroup != nil {\n\t\treturn b.InstanceGroup, nil\n\t}\n\n\tinstanceGroups, err := b.GetInstanceGroups(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif b.InstanceGroupName == \"\" {\n\t\treturn nil, fmt.Errorf(\"InstanceGroup name is missing\")\n\t}\n\n\t// Build full IG spec to ensure we end up with a valid IG\n\tfor i := range instanceGroups.Items {\n\t\tig := &instanceGroups.Items[i]\n\t\tif ig.Name == b.InstanceGroupName {\n\t\t\tb.InstanceGroup = ig\n\t\t\treturn ig, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"instance group %q not found\", b.InstanceGroupName)\n}\n\nfunc (b *ConfigBuilder) GetFullInstanceGroup(ctx context.Context) (*kops.InstanceGroup, error) {\n\tif b.fullInstanceGroup != nil {\n\t\treturn b.fullInstanceGroup, nil\n\t}\n","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/commands/toolbox_enroll.go#L534-L570","documentation":"ConfigBuilder.GetInstanceGroup requires b.InstanceGroupName to identify which instance group to fetch from the cluster. This sentinel error means the builder was used without that field set, so no group can be selected.","triggerScenarios":"Calling GetInstanceGroup (directly or via GetFullInstanceGroup) on a ConfigBuilder whose InstanceGroupName field was never set.","commonSituations":"Programmatic use of toolbox enroll/config builder where the --name/-ig flag wasn't wired into the builder; tests constructing a partial builder; a code path that only sets ClusterName but not InstanceGroupName.","solutions":["Set InstanceGroupName on the ConfigBuilder before calling GetInstanceGroup/GetFullInstanceGroup","Pass the instance-group flag through from the CLI invocation","Guard callers: check InstanceGroupName != \"\" and report a usage error early"],"exampleFix":"// before\nb := ConfigBuilder{ClusterName: \"c1.example.com\"}\nig, err := b.GetInstanceGroup(ctx) // \"InstanceGroup name is missing\"\n// after\nb := ConfigBuilder{ClusterName: \"c1.example.com\", InstanceGroupName: \"nodes\"}","handlingStrategy":"validation","validationCode":"if b.InstanceGroupName == \"\" {\n    return errors.New(\"--instance-group is required\")\n}","typeGuard":"func (b *ConfigBuilder) HasInstanceGroupName() bool { return b.InstanceGroupName != \"\" }","tryCatchPattern":null,"preventionTips":["Wire CLI flags into every ConfigBuilder field","Validate required builder fields at construction time","Document required fields for programmatic users"],"tags":["configuration","instance-group","validation"],"backgroundTag":"missing-required-config","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"}