{"record":{"id":"9e6626c88321f5f1","repo":"kubernetes/kops","slug":"can-only-promote-to-one-keyset-at-a-time","errorCode":null,"errorMessage":"can only promote to one keyset at a time","messagePattern":"can only promote to one keyset at a time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/promote_keypair.go","lineNumber":92,"sourceCode":"\t\tUse:     \"keypair {KEYSET [ID] | all}\",\n\t\tShort:   promoteKeypairShort,\n\t\tLong:    promoteKeypairLong,\n\t\tExample: promoteKeypairExample,\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 name of keyset promote keypair in\")\n\t\t\t}\n\n\t\t\toptions.Keyset = args[0]\n\n\t\t\tif len(args) > 2 {\n\t\t\t\treturn fmt.Errorf(\"can only promote to one keyset at a time\")\n\t\t\t}\n\t\t\tif len(args) > 1 {\n\t\t\t\tif options.Keyset == \"all\" {\n\t\t\t\t\treturn fmt.Errorf(\"cannot specify ID with \\\"all\\\"\")\n\t\t\t\t}\n\n\t\t\t\toptions.KeypairID = args[1]\n\t\t\t}\n\n\t\t\treturn nil\n\t\t},\n\t\tValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {\n\t\t\treturn completePromoteKeyset(cmd.Context(), f, options, args, toComplete)\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn RunPromoteKeypair(cmd.Context(), f, out, options)\n\t\t},\n\t}","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/promote_keypair.go#L74-L110","documentation":"The promote keypair command's argument validator allows at most two positional args (KEYSET and optionally ID); this fires when more than two were supplied, since promotion targets exactly one keyset (and one keypair) at a time.","triggerScenarios":"Running e.g. `kops promote keypair kubernetes-ca 3 all --name <cluster>` or otherwise passing multiple keysets/extra arguments.","commonSituations":"Listing several keysets hoping for a batch promotion; accidentally appending extra tokens from a script; misunderstanding the ID argument as an additional keyset.","solutions":["Pass exactly one keyset (and optionally one ID): `kops promote keypair <keyset> [ID] --name <cluster>`","Use `all` instead of enumerating keysets: `kops promote keypair all --name <cluster>`","Remove extra positional arguments from your script line"],"exampleFix":"// before\nkops promote keypair kubernetes-ca apiserver-aggregator-ca --name c\n// after\nkops promote keypair all --name c","handlingStrategy":"validation","validationCode":"args=(kubernetes-ca 3 all)\n[ ${#args[@]} -le 2 ] || { echo \"max args: keyset [ID]\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never enumerate multiple keysets; use `all`","Keep promotion commands to `keyset [ID]` form","Review scripts that build argument lists dynamically"],"tags":["cli","argument-validation"],"backgroundTag":"too-many-arguments","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"}