Fix/prevent returning error from external cache (#1576)

* Prevent returning error from external cache query

* link comment

* fix spell and remove unnecessary return
This commit is contained in:
Maycon Santos 2024-02-13 13:10:17 +01:00 committed by GitHub
parent e890fdae54
commit cf87f1e702
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1223,6 +1223,8 @@ func (am *DefaultAccountManager) lookupUserInCache(userID string, account *Accou
} }
} }
// add extra check on external cache manager. We may get to this point when the user is not yet findable in IDP,
// or it didn't have its metadata updated with am.addAccountIDToIDPAppMeta
user, err := account.FindUser(userID) user, err := account.FindUser(userID)
if err != nil { if err != nil {
log.Errorf("failed finding user %s in account %s", userID, account.Id) log.Errorf("failed finding user %s in account %s", userID, account.Id)
@ -1232,8 +1234,7 @@ func (am *DefaultAccountManager) lookupUserInCache(userID string, account *Accou
key := user.IntegrationReference.CacheKey(account.Id, userID) key := user.IntegrationReference.CacheKey(account.Id, userID)
ud, err := am.externalCacheManager.Get(am.ctx, key) 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) log.Debugf("failed to get externalCache for key: %s, error: %s", key, err)
return nil, status.Errorf(status.NotFound, "user %s not found in the IdP", userID)
} }
return ud, nil return ud, nil