{"record":{"id":"a6df9ed339e171c6","repo":"portainer/portainer","slug":"failed-to-get-service-account-q-w","errorCode":null,"errorMessage":"failed to get service account %q: %w","messagePattern":"failed to get service account %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/kubernetes/cli/service_account.go","lineNumber":365,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tupdated = append(updated, ref)\n\t}\n\n\tif !changed {\n\t\treturn nil\n\t}\n\n\tsa.ImagePullSecrets = updated\n\n\t_, err = kcl.cli.CoreV1().ServiceAccounts(namespace).Update(context.TODO(), sa, metav1.UpdateOptions{})\n\treturn err\n}\n\nfunc (kcl *KubeClient) UpdateServiceAccountImagePullSecrets(namespace, name string, secretNames []string) error {\n\tsa, err := kcl.cli.CoreV1().ServiceAccounts(namespace).Get(context.TODO(), name, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get service account %q: %w\", name, err)\n\t}\n\n\trefs := make([]corev1.LocalObjectReference, 0, len(secretNames))\n\tfor _, s := range secretNames {\n\t\trefs = append(refs, corev1.LocalObjectReference{Name: s})\n\t}\n\tsa.ImagePullSecrets = refs\n\n\t_, err = kcl.cli.CoreV1().ServiceAccounts(namespace).Update(context.TODO(), sa, metav1.UpdateOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to update service account %q: %w\", name, err)\n\t}\n\treturn nil\n}\n\nfunc (kcl *KubeClient) ensureNamespaceAccessForServiceAccount(serviceAccountName, namespace string) error {\n\troleBindingName := namespaceClusterRoleBindingName(namespace, kcl.instanceID)\n","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/api/kubernetes/cli/service_account.go#L347-L383","documentation":"Error \"failed to get service account %q: %w\" thrown in portainer/portainer.","triggerScenarios":"Thrown at api/kubernetes/cli/service_account.go:365 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"}