From 5ed1441ddb7e3a6e3bf364018d7d3ac52e4021fc Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 19 Aug 2023 08:34:03 +1000 Subject: [PATCH] fix illegal values in redis jobs 1. populate_streams_get_audience This tries to set status_reply_parent_privacy as None if there is no status.reply_parent, but None is not a valid value for privacy. This doesn't appear to be breaking anything but does result in a lot of error messages in the logs. I have set this to equal the original status.privacy - this won't realy have any effect since it only happens when there is no parent, however we could set this to "direct" if we want to be highly cautious. 2. rerank_user_task Again, this doesn't seem to caused major issues, but is throwing errors if the user in question no longer exists for some reason. This commit checks whether 'user' exists before attempting to rerank. --- bookwyrm/activitystreams.py | 2 +- bookwyrm/suggested_users.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 71f9e42d77..42f99e2093 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -112,7 +112,7 @@ def _get_audience(self, status): # pylint: disable=no-self-use trace.get_current_span().set_attribute("status_privacy", status.privacy) trace.get_current_span().set_attribute( "status_reply_parent_privacy", - status.reply_parent.privacy if status.reply_parent else None, + status.reply_parent.privacy if status.reply_parent else status.privacy, ) # direct messages don't appear in feeds, direct comments/reviews/etc do if status.privacy == "direct" and status.status_type == "Note": diff --git a/bookwyrm/suggested_users.py b/bookwyrm/suggested_users.py index d897feff7e..3e9bef9c43 100644 --- a/bookwyrm/suggested_users.py +++ b/bookwyrm/suggested_users.py @@ -254,7 +254,8 @@ def rerank_suggestions_task(user_id): def rerank_user_task(user_id, update_only=False): """do the hard work in celery""" user = models.User.objects.get(id=user_id) - suggested_users.rerank_obj(user, update_only=update_only) + if user: + suggested_users.rerank_obj(user, update_only=update_only) @app.task(queue=SUGGESTED_USERS)