From 9d15127841fa81ed1713c0c5963f2aa632f3a58f Mon Sep 17 00:00:00 2001 From: tobi Date: Tue, 16 Apr 2024 12:44:40 +0200 Subject: [PATCH] rejig logging a bit --- internal/federation/dereferencing/account.go | 38 ++++++------------- .../federation/dereferencing/collection.go | 2 +- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go index 8fe2586b4..e8d32f58a 100644 --- a/internal/federation/dereferencing/account.go +++ b/internal/federation/dereferencing/account.go @@ -1062,10 +1062,9 @@ func (d *Dereferencer) fetchRemoteAccountStats(ctx context.Context, account *gts account.FollowersURI, requestUser, ); err != nil { - // Something up with the URL, - // log this but don't bail. - log.Errorf(ctx, - "bad followers URI for account @%s@%s: %v", + // Log this but don't bail. + log.Warnf(ctx, + "couldn't count followers for @%s@%s: %v", account.Username, account.Domain, err, ) } else if count > 0 { @@ -1079,10 +1078,9 @@ func (d *Dereferencer) fetchRemoteAccountStats(ctx context.Context, account *gts account.FollowingURI, requestUser, ); err != nil { - // Something up with the URL, - // log this but don't bail. - log.Errorf(ctx, - "bad following URI for account @%s@%s: %v", + // Log this but don't bail. + log.Warnf(ctx, + "couldn't count following for @%s@%s: %v", account.Username, account.Domain, err, ) } else if count > 0 { @@ -1096,10 +1094,9 @@ func (d *Dereferencer) fetchRemoteAccountStats(ctx context.Context, account *gts account.OutboxURI, requestUser, ); err != nil { - // Something up with the URL, - // log this but don't bail. - log.Errorf(ctx, - "bad outbox URI for account @%s@%s: %v", + // Log this but don't bail. + log.Warnf(ctx, + "couldn't count statuses for @%s@%s: %v", account.Username, account.Domain, err, ) } else if count > 0 { @@ -1127,13 +1124,8 @@ func (d *Dereferencer) fetchRemoteAccountStats(ctx context.Context, account *gts // a positive integer, or -1 if total items // cannot be counted. // -// Only returns an error if provided uriStr -// is not empty and not parseable. Actual -// dereferencing errors are ignored, on the -// basis that it's not a show stopper if an -// error occurs since these numbers are not -// very important, but malformed URIs are -// kind of significant. +// Error will be returned for invalid non-empty +// URIs or dereferencing isses. func (d *Dereferencer) countCollection( ctx context.Context, uriStr string, @@ -1150,13 +1142,7 @@ func (d *Dereferencer) countCollection( collect, err := d.dereferenceCollection(ctx, requestUser, uri) if err != nil { - // Just log for debug, we don't - // mind if we can't fetch this. - log.Debugf(ctx, - "error dereferencing %s: %v", - uriStr, err, - ) - return -1, nil + return -1, err } return collect.TotalItems(), nil diff --git a/internal/federation/dereferencing/collection.go b/internal/federation/dereferencing/collection.go index 07f56c952..1a9f1555b 100644 --- a/internal/federation/dereferencing/collection.go +++ b/internal/federation/dereferencing/collection.go @@ -40,7 +40,7 @@ func (d *Dereferencer) dereferenceCollection(ctx context.Context, username strin rsp, err := transport.Dereference(ctx, pageIRI) if err != nil { - return nil, gtserror.Newf("error deferencing %s: %w", pageIRI.String(), err) + return nil, gtserror.Newf("error dereferencing %s: %w", pageIRI.String(), err) } collect, err := ap.ResolveCollection(ctx, rsp.Body)