Skip weekly summary email for users with no accessible lab#1609
Open
davmlaw wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
send_summary_email_to_usernow skips users who have no accessible lab instead of crashing.Why
The weekly summary email task (
send_summary_emails→send_summary_email_to_user) calledLabPickerData.for_user(user)with no lab selection. For a user with no accessible lab,LabSelection.from_userproduces an emptyselected_lab_setand raisesValueError: 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 adebugmessage and returnsFalserather than attempting to build the summary. Placing the guard insend_summary_email_to_userprotects all three callers (the celery task, thesend_weekly_emailsmanagement command, and the vcauth admin action).Behaviour for users who do have a lab is unchanged.
Addresses #1602
🤖 Generated with Claude Code