{"record":{"id":"27ee954ea3bfdabb","repo":"kubernetes/kops","slug":"must-specify-name-of-keyset-to-trust-keypair-in","errorCode":null,"errorMessage":"must specify name of keyset to trust keypair in","messagePattern":"must specify name of keyset to trust keypair in","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/trust_keypair.go","lineNumber":71,"sourceCode":"\tKeypairIDs  []string\n}\n\nfunc NewCmdTrustKeypair(f *util.Factory, out io.Writer) *cobra.Command {\n\toptions := &TrustKeypairOptions{}\n\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},","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/trust_keypair.go#L53-L89","documentation":"Argument validation in `kops trust keypair`: the command requires KEYSET plus one or more keypair IDs as positional arguments, and this guard fires when no arguments are supplied. Pure usage validation before any API call.","triggerScenarios":"Running `kops trust keypair --name <cluster>` with zero positional arguments.","commonSituations":"Command truncated in scripts; misunderstanding that keyset is optional; copy-paste dropping the keyset argument.","solutions":["Provide the keyset name as the first argument, e.g. `kops trust keypair --name <cluster> kubernetes-ca <id>`.","Run `kops get keypairs --name <cluster>` to list available keysets.","Check the command's help output for argument order: keyset first, then keypair IDs."],"exampleFix":"// before\nkops trust keypair --name mycluster.example.com 2026-01-01\n// after\nkops trust keypair --name mycluster.example.com kubernetes-ca 2026-01-01","handlingStrategy":"validation","validationCode":"if len(positionalArgs) < 1 { return errors.New(\"keyset name 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 name of keyset\") { append keyset argument and retry }","preventionTips":["Check argument count before invoking in scripts","Consult `kops trust keypair --help` for argument order","Build command lines from variables rather than manual concatenation"],"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"}