From dd14db6478fbd661baa950da530f19c0793aa424 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Mon, 12 Feb 2024 21:54:16 +0100 Subject: [PATCH] Properly handle cache error and return userdata (#1571) --- management/server/account.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/management/server/account.go b/management/server/account.go index 6af0a39d6d5..91b0e4883f1 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -1231,14 +1231,12 @@ func (am *DefaultAccountManager) lookupUserInCache(userID string, account *Accou key := user.IntegrationReference.CacheKey(account.Id, userID) ud, err := am.externalCacheManager.Get(am.ctx, key) - if err == nil { + if err != nil { log.Errorf("failed to get externalCache for key: %s, error: %s", key, err) - return ud, status.Errorf(status.NotFound, "user %s not found in the IdP", userID) + return nil, status.Errorf(status.NotFound, "user %s not found in the IdP", userID) } - log.Infof("user %s not found in any cache", userID) - - return nil, nil //nolint:nilnil + return ud, nil } func (am *DefaultAccountManager) refreshCache(accountID string) ([]*idp.UserData, error) {