{"record":{"id":"40fadf89c3449b62","repo":"kubernetes/kops","slug":"must-specify-names-of-keypairs-to-trust-keypair-in","errorCode":null,"errorMessage":"must specify names of keypairs to trust keypair in","messagePattern":"must specify names of keypairs to trust keypair in","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/trust_keypair.go","lineNumber":76,"sourceCode":"\n\tcmd := &cobra.Command{\n\t\tUse:     \"keypair KEYSET ID...\",\n\t\tShort:   trustKeypairShort,\n\t\tLong:    trustKeypairLong,\n\t\tExample: trustKeypairExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\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 to trust keypair in\")\n\t\t\t}\n\t\t\toptions.Keyset = args[0]\n\n\t\t\tif len(args) == 1 {\n\t\t\t\treturn fmt.Errorf(\"must specify names of keypairs to trust keypair in\")\n\t\t\t}\n\t\t\toptions.KeypairIDs = args[1:]\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 completeTrustKeyset(cmd.Context(), f, options, args, toComplete)\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tctx := cmd.Context()\n\n\t\t\treturn RunTrustKeypair(ctx, f, out, options)\n\t\t},\n\t}\n\n\treturn cmd\n}\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/trust_keypair.go#L58-L94","documentation":"`kops trust keypair` requires the keyset name followed by one or more keypair IDs to trust. If only one argument (the keyset) is given, the Args validator returns this error because no keypair IDs were supplied.","triggerScenarios":"Running `kops trust keypair --name <cluster> <keyset>` with exactly one positional argument and no keypair IDs.","commonSituations":"Stopping after the keyset argument by mistake; forgetting to paste the keypair ID from `kops get keypairs` output.","solutions":["Append one or more keypair IDs: `kops trust keypair --name <cluster> <keyset> <id1> [<id2>...]`.","List keypair IDs first with `kops get keypairs --name <cluster> <keyset>` and copy the desired ones.","See `kops trust keypair --help` for the expected argument list."],"exampleFix":"// before\nkops trust keypair --name mycluster.example.com kubernetes-ca\n// after\nkops trust keypair --name mycluster.example.com kubernetes-ca 2026-01-01","handlingStrategy":"validation","validationCode":"if len(positionalArgs) < 2 { return errors.New(\"keypair IDs required: kops trust keypair <keyset> <keypair-id>...\") }","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"kops\", \"trust\", \"keypair\", cmdArgs...).CombinedOutput()\nif strings.Contains(string(out), \"must specify names of keypairs\") { fetch keypair IDs via `kops get keypairs` and append them }","preventionTips":["Resolve keypair IDs from `kops get keypairs` before constructing the command","Validate argument count >= 2 in wrapper scripts","Pass multiple IDs in one invocation rather than looping when practical"],"tags":["cli","validation","arguments"],"backgroundTag":"missing-required-argument","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"}