{"record":{"id":"3baf0022f4d79fc2","repo":"kubernetes/kops","slug":"can-only-create-one-instance-group-at-a-time-3baf00","errorCode":null,"errorMessage":"can only create one instance group at a time","messagePattern":"can only create one instance group at a time","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":136,"sourceCode":"\t\ttoolboxInstanceSelectorLong,\n\t\ttoolboxInstanceSelectorExample,\n\t\tnil,\n\t)\n\tcommandline.Command.Args = func(cmd *cobra.Command, args []string) error {\n\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\n\t\tif options.ClusterName == \"\" {\n\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t}\n\n\t\tif len(args) == 0 {\n\t\t\treturn fmt.Errorf(\"must specify name of instance group to create\")\n\t\t}\n\n\t\toptions.InstanceGroupName = args[0]\n\n\t\tif len(args) != 1 {\n\t\t\treturn fmt.Errorf(\"can only create one instance group at a time\")\n\t\t}\n\n\t\tif err := processAndValidateFlags(&commandline); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsetInstanceSelectorOpts(options, &commandline)\n\n\t\treturn nil\n\t}\n\tcommandline.Command.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\tcommandutils.ConfigureKlogForCompletion()\n\t\tif len(args) == 1 && rootCommand.ClusterName(false) == \"\" {\n\t\t\treturn []string{\"--name\"}, cobra.ShellCompDirectiveNoFileComp\n\t\t}\n\t\treturn nil, cobra.ShellCompDirectiveNoFileComp\n\t}\n\tcommandline.Command.RunE = func(cmd *cobra.Command, args []string) error {\n\t\treturn RunToolboxInstanceSelector(cmd.Context(), f, out, &commandline, options)","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L118-L154","documentation":"Argument-count guard in the cobra Args validator of `kops toolbox instance-selector`: more than one positional instance-group name was supplied. The command accepts exactly one instance group name per invocation.","triggerScenarios":"Running `kops toolbox instance-selector nodes bastions --name <cluster>` or otherwise passing two or more positional names.","commonSituations":"Trying to update several instance groups in one command; leftover args in a loop script; quoting mistakes splitting an argument into multiple positionals.","solutions":["Run the command once per instance group","Quote a single argument if it contains spaces (rare): \"my ig\"","Check shell variable quoting in scripts so an empty variable doesn't shift positions"],"exampleFix":"// before\nkops toolbox instance-selector nodes bastions --name mycluster.k8s.local\n// after\nkops toolbox instance-selector nodes --name mycluster.k8s.local\nkops toolbox instance-selector bastions --name mycluster.k8s.local","handlingStrategy":"validation","validationCode":"set -- ${EXTRA_ARGS:-}\nif [ \"$#\" -gt 1 ]; then\n  echo \"only one instance group per invocation\" >&2\n  exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Loop over instance groups, invoking the command once per group","Quote variables so they expand to a single argument","Sanitize positional args in wrapper scripts"],"tags":["cli","flag-validation","instance-selector","usage"],"backgroundTag":"invalid-argument-count","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}