Browse Source

fix(weekly_email): Do not fail if user is not specified (#45982)

The _admin interface allows scheduling the weekly email report for a
user that would have access to all reports, thus, a specific `user` is
not set.

Fixes [SENTRY-ZN8](https://sentry.sentry.io/issues/4011905281)
Armen Zambrano G 2 years ago
parent
commit
ee3c31b394
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/sentry/tasks/weekly_reports.py

+ 4 - 1
src/sentry/tasks/weekly_reports.py

@@ -770,7 +770,10 @@ def render_template_context(ctx, user):
             if ctx.organization.slug == "sentry":
                 logger.info(
                     "render_template_context.all_key_errors.num_projects",
-                    extra={"user_id": user.id, "num_user_projects": len(user_projects)},
+                    extra={
+                        "user_id": user.id if user else "",
+                        "num_user_projects": len(user_projects),
+                    },
                 )
             for project_ctx in user_projects:
                 if ctx.organization.slug == "sentry":