{"record":{"id":"87bf5eb1f774fb63","repo":"kubernetes/kops","slug":"name-is-required-87bf5e","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_instancegroup.go","lineNumber":72,"sourceCode":"\tYes         bool\n\tClusterName string\n\tGroupName   string\n}\n\nfunc NewCmdDeleteInstanceGroup(f *util.Factory, out io.Writer) *cobra.Command {\n\toptions := &DeleteInstanceGroupOptions{}\n\n\tcmd := &cobra.Command{\n\t\tUse:     \"instancegroup INSTANCE_GROUP\",\n\t\tAliases: []string{\"instancegroups\", \"ig\"},\n\t\tShort:   deleteInstanceGroupShort,\n\t\tLong:    deleteInstanceGroupLong,\n\t\tExample: deleteInstanceGroupExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\n\t\t\tif options.ClusterName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn fmt.Errorf(\"must specify the name of the instance group to delete\")\n\t\t\t}\n\n\t\t\toptions.GroupName = args[0]\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"can only delete one instance group at a time\")\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tValidArgsFunction: completeInstanceGroup(f, nil, &[]string{kops.InstanceGroupRoleControlPlane.ToLowerString()}),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tctx := cmd.Context()\n","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_instancegroup.go#L54-L90","documentation":"`kops delete instancegroup` validates its arguments in cobra's Args function before running. If rootCommand.ClusterName(true) returns an empty string — i.e. neither the --name flag nor a KOPS_CLUSTER_NAME was supplied and no cluster state exists — the command aborts with this error. kops needs the cluster name to locate and modify the instance group.","triggerScenarios":"Running `kops delete instancegroup workers` without --name, without KOPS_CLUSTER_NAME set, and outside a kops state-store context that can infer the cluster.","commonSituations":"Scripting/CI where the --name flag was dropped; relying on KOPS_CLUSTER_NAME that isn't exported in the shell; deleting an instance group from a directory other than where the cluster name was set via dotenv/flags.","solutions":["Pass the cluster explicitly: `kops delete instancegroup --name <cluster-name> workers`.","Export KOPS_CLUSTER_NAME=<cluster-name> in the shell or CI environment.","Check scripts/aliases that previously set --name and restore it."],"exampleFix":"// before\n$ kops delete instancegroup workers\nerror: --name is required\n// after\n$ kops delete instancegroup --name prod.example.com workers","handlingStrategy":"validation","validationCode":"[ -n \"${KOPS_CLUSTER_NAME:-$CLUSTER_NAME}\" ] || { echo \"set --name or KOPS_CLUSTER_NAME\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --name in scripts and CI instead of relying on ambient state.","Export KOPS_CLUSTER_NAME in shell profiles/CI environments.","Set kops state store config consistently across automation."],"tags":["cli","kops","missing-flag","validation"],"backgroundTag":"missing-required-flag","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"}