Skip to content

Skip weekly summary email for users with no accessible lab#1609

Open
davmlaw wants to merge 1 commit into
masterfrom
issue_1602_weekly_email_no_lab
Open

Skip weekly summary email for users with no accessible lab#1609
davmlaw wants to merge 1 commit into
masterfrom
issue_1602_weekly_email_no_lab

Conversation

@davmlaw

@davmlaw davmlaw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What

send_summary_email_to_user now skips users who have no accessible lab instead of crashing.

Why

The weekly summary email task (send_summary_emailssend_summary_email_to_user) called LabPickerData.for_user(user) with no lab selection. For a user with no accessible lab, LabSelection.from_user produces an empty selected_lab_set and raises ValueError: You do not have access to lab selection : None. This crashed the task per-user and accounted for 237 occurrences across shariant prod/demo/test.

The fix adds an early guard in send_summary_email_to_user: if the user has no valid (active-organization) lab, it logs a debug message and returns False rather than attempting to build the summary. Placing the guard in send_summary_email_to_user protects all three callers (the celery task, the send_weekly_emails management command, and the vcauth admin action).

Behaviour for users who do have a lab is unchanged.

Addresses #1602

🤖 Generated with Claude Code

send_summary_email_to_user called LabPickerData.for_user(user) with no
selection. For a user with no accessible lab, LabSelection.from_user
ends up with an empty selected_lab_set and raises
"ValueError: You do not have access to lab selection : None",
crashing the weekly summary email task.

Guard up front: if the user has no valid (active-org) lab, log a debug
note and return False rather than building the summary. The guard lives
in send_summary_email_to_user so all callers (the celery task, the
management command and the vcauth admin action) are protected. Users who
do have a lab are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant