{"record":{"id":"e9d8e5d69ff45951","repo":"kubernetes/kops","slug":"keypair-not-found","errorCode":null,"errorMessage":"keypair not found","messagePattern":"keypair not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/distrust_keypair.go","lineNumber":175,"sourceCode":"\t\tfor id, item := range keyset.Items {\n\t\t\tif item.DistrustTimestamp == nil && item.Certificate.Certificate.SerialNumber.Cmp(primarySerial) < 0 {\n\t\t\t\tkeypairIDs = append(keypairIDs, id)\n\t\t\t}\n\t\t}\n\n\t\tif len(keypairIDs) == 0 {\n\t\t\tklog.Infof(\"No %s keypairs older than the primary.\", name)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tfor _, id := range keypairIDs {\n\t\tif id == keyset.Primary.Id {\n\t\t\treturn fmt.Errorf(\"cannot distrust the primary keypair\")\n\t\t}\n\t\titem := keyset.Items[id]\n\t\tif item == nil {\n\t\t\treturn fmt.Errorf(\"keypair not found\")\n\t\t}\n\n\t\tif item.DistrustTimestamp != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tnow := time.Now().UTC().Round(0)\n\t\titem.DistrustTimestamp = &now\n\n\t\tif err := keyStore.StoreKeyset(ctx, name, keyset); err != nil {\n\t\t\treturn fmt.Errorf(\"error storing keyset: %w\", err)\n\t\t}\n\n\t\tfmt.Fprintf(out, \"Distrusted %s %s\\n\", name, id)\n\t}\n\n\treturn nil\n}","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/distrust_keypair.go#L157-L193","documentation":"While distrustKeypair iterates the requested keypair IDs, one ID has no corresponding item in keyset.Items - the ID does not match any certificate in the named keyset. Other IDs may be valid; the loop aborts at the bad one.","triggerScenarios":"Thrown at cmd/kops/distrust_keypair.go:175 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["List the keyset's keypair IDs to find valid IDs","Check the ID for typos or staleness (it may refer to a rotated-away keypair)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}