{"record":{"id":"ca6449fe849ef3c5","repo":"portainer/portainer","slug":"an-error-occurred-during-the-setsecretsisused-oper-ca6449","errorCode":null,"errorMessage":"an error occurred during the SetSecretsIsUsed operation, unable to fetch service accounts. Error: %w","messagePattern":"an error occurred during the SetSecretsIsUsed operation, unable to fetch service accounts\\. Error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/kubernetes/cli/secret.go","lineNumber":213,"sourceCode":"\t\tresult.Data = secretDataMap\n\t}\n\n\treturn result\n}\n\n// SetSecretsIsUsed combines the secrets with the applications that use them.\n// the function fetches all the pods and service accounts in the cluster and checks if the secret is used by any of them.\n// if the secret is used by a pod or service account, the secret is marked as used.\n// otherwise, the secret is returned as is.\nfunc (kcl *KubeClient) SetSecretsIsUsed(secrets *[]models.K8sSecret) error {\n\tportainerApplicationResources, err := kcl.fetchAllApplicationsListResources(\"\", metav1.ListOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"an error occurred during the SetSecretsIsUsed operation, unable to fetch Portainer application resources. Error: %w\", err)\n\t}\n\n\tserviceAccounts, err := kcl.GetServiceAccounts(\"\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"an error occurred during the SetSecretsIsUsed operation, unable to fetch service accounts. Error: %w\", err)\n\t}\n\n\tfor i := range *secrets {\n\t\tsecret := &(*secrets)[i]\n\n\t\tif isSecretUsedByServiceAccount(*secret, serviceAccounts) {\n\t\t\tsecret.IsUsed = true\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, pod := range portainerApplicationResources.Pods {\n\t\t\tif isPodUsingSecret(&pod, *secret) {\n\t\t\t\tsecret.IsUsed = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/kubernetes/cli/secret.go#L195-L231","documentation":"Error \"an error occurred during the SetSecretsIsUsed operation, unable to fetch service accounts. Error: %w\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/kubernetes/cli/secret.go:213 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":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}