{"record":{"id":"f64c9e8a5f1759a6","repo":"rancher/rancher","slug":"token-s-is-already-in-use-by-secret","errorCode":null,"errorMessage":"token %s is already in use by secret","messagePattern":"token (.+?) is already in use by secret","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/api/norman/customization/cred/store.go","lineNumber":154,"sourceCode":"\t\t\t}\n\n\t\t\tknownTokens := make(Set[string])\n\t\t\tfor _, secret := range secrets {\n\t\t\t\tif len(secret.Data[\"harvestercredentialConfig-kubeconfigContent\"]) == 0 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\terr := TokenNamesFromContent(secret.Data[\"harvestercredentialConfig-kubeconfigContent\"], knownTokens)\n\t\t\t\tif err != nil {\n\t\t\t\t\t// If a secret is all messed up, let the user do whatever they want: it shouldn't be usable anyway and will be remediated when updated.\n\t\t\t\t\tlogrus.Errorf(\"failed to get tokens from secret: %v\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor tokenName := range tokens {\n\t\t\t\tif _, ok := knownTokens[tokenName]; ok {\n\t\t\t\t\treturn fmt.Errorf(\"token %s is already in use by secret\", tokenName)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (s *Store) Create(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}) (map[string]interface{}, error) {\n\tif err := s.processHarvesterCloudCredential(data); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to process harvester cloud credential: %w\", err)\n\t}\n\n\treturn s.Store.Create(apiContext, schema, data)\n}\n\nfunc (s *Store) Update(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, id string) (map[string]interface{}, error) {\n\tif err := s.processHarvesterCloudCredential(data); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to process harvester cloud credential: %w\", err)","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/rancher/rancher/blob/932558d4e68565aff2d2f36e89ec4a391b06e7c5/pkg/api/norman/customization/cred/store.go#L136-L172","documentation":"Error \"token %s is already in use by secret\" thrown in rancher/rancher.","triggerScenarios":"Thrown at pkg/api/norman/customization/cred/store.go:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"932558d4e68565aff2d2f36e89ec4a391b06e7c5","analyzedAt":"2026-08-16T04:37:02.125Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}