From 08cb8a3385d9c756ce16ff7d2c4a260d9394f058 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 28 Sep 2021 16:19:13 +0200 Subject: [PATCH] skip account on error instead of returning error (#251) * skip account on error instead of returning error * still return error on a real error --- internal/federation/federatingdb/followers.go | 10 +++++++++- internal/federation/federatingdb/following.go | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/federation/federatingdb/followers.go b/internal/federation/federatingdb/followers.go index c7f636a12..69c68b8b9 100644 --- a/internal/federation/federatingdb/followers.go +++ b/internal/federation/federatingdb/followers.go @@ -54,7 +54,15 @@ func (f *federatingDB) Followers(ctx context.Context, actorIRI *url.URL) (follow if follow.Account == nil { followAccount, err := f.db.GetAccountByID(ctx, follow.AccountID) if err != nil { - return nil, fmt.Errorf("FOLLOWERS: db error getting account id %s: %s", follow.AccountID, err) + errWrapped := fmt.Errorf("FOLLOWERS: db error getting account id %s: %s", follow.AccountID, err) + if err == db.ErrNoEntries { + // no entry for this account id so it's probably been deleted and we haven't caught up yet + l.Error(errWrapped) + continue + } else { + // proper error + return nil, errWrapped + } } follow.Account = followAccount } diff --git a/internal/federation/federatingdb/following.go b/internal/federation/federatingdb/following.go index 9d5c0693c..a36f4e203 100644 --- a/internal/federation/federatingdb/following.go +++ b/internal/federation/federatingdb/following.go @@ -8,6 +8,7 @@ import ( "github.com/go-fed/activity/streams" "github.com/go-fed/activity/streams/vocab" "github.com/sirupsen/logrus" + "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/util" ) @@ -67,7 +68,15 @@ func (f *federatingDB) Following(ctx context.Context, actorIRI *url.URL) (follow if follow.Account == nil { followAccount, err := f.db.GetAccountByID(ctx, follow.AccountID) if err != nil { - return nil, fmt.Errorf("FOLLOWING: db error getting account id %s: %s", follow.AccountID, err) + errWrapped := fmt.Errorf("FOLLOWING: db error getting account id %s: %s", follow.AccountID, err) + if err == db.ErrNoEntries { + // no entry for this account id so it's probably been deleted and we haven't caught up yet + l.Error(errWrapped) + continue + } else { + // proper error + return nil, errWrapped + } } follow.Account = followAccount }