{"record":{"id":"cb828f1e0f5751b1","repo":"kubernetes/kops","slug":"no-keypairs-found","errorCode":null,"errorMessage":"no keypairs found","messagePattern":"no keypairs found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/get_keypairs.go","lineNumber":189,"sourceCode":"\t}\n\n\tcluster, err := clientset.GetCluster(ctx, options.ClusterName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkeyStore, err := clientset.KeyStore(cluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\titems, err := listKeypairs(keyStore, options.KeysetNames, options.Distrusted)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(items) == 0 {\n\t\treturn fmt.Errorf(\"no keypairs found\")\n\t}\n\tswitch options.Output {\n\n\tcase OutputTable:\n\t\tt := &tables.Table{}\n\t\tt.AddColumn(\"NAME\", func(i *keypairItem) string {\n\t\t\treturn i.Name\n\t\t})\n\t\tt.AddColumn(\"ID\", func(i *keypairItem) string {\n\t\t\treturn i.ID\n\t\t})\n\t\tt.AddColumn(\"DISTRUSTED\", func(i *keypairItem) string {\n\t\t\tif i.DistrustTimestamp != nil {\n\t\t\t\treturn i.DistrustTimestamp.Local().Format(\"2006-01-02\")\n\t\t\t}\n\t\t\treturn \"\"\n\t\t})\n\t\tt.AddColumn(\"ISSUED\", func(i *keypairItem) string {","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/get_keypairs.go#L171-L207","documentation":"After listing keysets, RunGetKeypairs checks whether any keypair items were returned. If listKeypairs produced an empty slice — no keysets in the store, or none matching the requested names / not including distrusted ones — the command returns \"no keypairs found\" instead of rendering empty output.","triggerScenarios":"`kops get keypairs` against a cluster whose state store has no keysets; `kops get keypairs <name>` where <name> does not match any keyset (names filter drops everything); keypairs exist but are all distrusted and --distrusted was not passed.","commonSituations":"Typo'd keyset name (e.g. `kubectl` instead of `kubernetes-ca`); querying a freshly created cluster before any rotate; expecting distrusted/retired keypairs to appear without the --distrusted flag; pointing at the wrong cluster via --name.","solutions":["Run `kops get keypairs` with no name filter to list all keysets and confirm what exists.","Add --distrusted if you expect retired/distrusted keypairs to be listed.","Verify you are targeting the right cluster with --name <cluster>.","If the store is genuinely empty, create the cluster or rotate keys (`kops update keys`) to populate keysets."],"exampleFix":"// before\nkops get keypairs kubelet-api   # no such keyset\n// after\nkops get keypairs                # list available keysets first","handlingStrategy":"validation","validationCode":"# confirm keysets exist before filtering by name\nkops get keypairs --name \"$CLUSTER\" || true   # list all; then pick a valid name","typeGuard":null,"tryCatchPattern":"out, err := runKopsOut(\"get\", \"keypairs\", \"--name\", cluster)\nif err != nil {\n\tif strings.Contains(err.Error(), \"no keypairs found\") {\n\t\t// empty result: fall back to listing all keysets or add --distrusted\n\t}\n\treturn err\n}","preventionTips":["List all keysets first, then filter by an exact name copy-pasted from that output.","Pass --distrusted when retired/distrusted keypairs are expected.","Confirm --name targets the intended cluster.","Treat empty results as a distinct case in automation rather than a hard failure."],"tags":["keypairs","empty-result","cli"],"backgroundTag":"no-results-found","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"}