{"record":{"id":"4fa22b9b29c8f4cc","repo":"kubernetes/kops","slug":"cannot-specify-id-with-all-4fa22b","errorCode":null,"errorMessage":"cannot specify ID with \"all\"","messagePattern":"cannot specify ID with \"all\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/promote_keypair.go","lineNumber":96,"sourceCode":"\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}\n\n\treturn cmd\n}\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/promote_keypair.go#L78-L114","documentation":"The promote keypair validator rejects combining the keyword 'all' with an explicit keypair ID argument: 'all' promotes every rotatable keyset's primary, so an individual ID is not meaningful in that form.","triggerScenarios":"Running `kops promote keypair all <ID> --name <cluster>` — i.e. keyset \"all\" with a second positional argument interpreted as the keypair ID.","commonSituations":"Reusing a command template that had a hardcoded ID while switching the keyset to \"all\"; scripting that always appends an ID variable even when empty-checks fail.","solutions":["Drop the ID: `kops promote keypair all --name <cluster>`","If you need to promote a specific ID, name the keyset explicitly: `kops promote keypair kubernetes-ca 3 --name <cluster>`","Fix the script so the ID argument is omitted when keyset is \"all\""],"exampleFix":"// before\nkops promote keypair all 2024-01-01-00-00-00 --name c\n// after\nkops promote keypair all --name c","handlingStrategy":"validation","validationCode":"if [ \"$KEYSET\" = \"all\" ] && [ -n \"$KEYPAIR_ID\" ]; then echo \"cannot combine 'all' with an ID\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass an ID when the keyset is explicit","Guard scripted ID-appending logic on keyset != \"all\"","Prefer promoting `all` without IDs"],"tags":["cli","argument-validation","keypair"],"backgroundTag":"conflicting-arguments","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"}