Repository: openreview/openreview-py (language: python)

Issue:
Venue class: recruitment process should check if a profile contains an email otherwise save it in the error message
Instead of showing the exceptions. 


Discussion / hints:

Fix patch:
diff --git a/openreview/venue/recruitment.py b/openreview/venue/recruitment.py
index 31fdd7305..a7a0e4683 100644
--- a/openreview/venue/recruitment.py
+++ b/openreview/venue/recruitment.py
@@ -94,7 +94,22 @@ def invite_committee(self,
             invited_group_ids=list(set(invited_roles) & set(memberships))
             member_group_ids=list(set(member_roles) & set(memberships))
 
-            if invited_group_ids:
+            profile_emails = []
+            profile = None
+            is_profile_id = email.startswith('~')
+            if is_profile_id:
+                profile = tools.get_profile(self.client, email)
+                profile_emails = profile.content['emails'] if profile else []
+
+            if profile and not profile_emails:
+                if 'profiles_without_email' not in recruitment_status['errors']:
+                    recruitment_status['errors']['profiles_without_email'] = []
+                recruitment_status['errors']['profiles_without_email'].append(email)
+            elif is_profile_id and not profile:
+                if 'invalid_profile_ids' not in recruitment_status['errors']:
+                    recruitment_status['errors']['invalid_profile_ids'] = []
+                recruitment_status['errors']['invalid_profile_ids'].append(email)
+            elif invited_group_ids:
                 invited_group_id=invited_group_ids[0]
                 if invited_group_id not in recruitment_status['already_invited']:
                     recruitment_status['already_invited'][invited_group_id] = [] 
@@ -106,7 +121,7 @@ def invite_committee(self,
                 recruitment_status['already_member'][member_group_id].append(email)
             else:
                 name = invitee_names[index] if (invitee_names and index < len(invitee_names)) else None
-                if not name and not email.startswith('~'):
+                if not name and not is_profile_id:
                     name = 'invitee'
                 try:
                     tools.recruit_reviewer(self.client, email, name,


Test patch:
diff --git a/tests/test_venue_request_v2.py b/tests/test_venue_request_v2.py
index 8e98bd12f..853d35cc9 100644
--- a/tests/test_venue_request_v2.py
+++ b/tests/test_venue_request_v2.py
@@ -600,7 +600,7 @@ def test_venue_recruitment_tilde_IDs(self, client, test_client, selenium, reques
         # assert [btn for btn in buttons if btn.text == 'Recruitment']
         helpers.create_user('reviewer_one_tilde_v2@mail.com', 'Reviewer', 'OneTildeV')
         helpers.create_user('reviewer_two_tilde_v2@mail.com', 'Reviewer', 'TwoTildeV')
-        reviewer_details = '''~Reviewer_OneTildeV1\n~Reviewer_TwoTildeV1'''
+        reviewer_details = '''~Reviewer_OneTildeV1\n~Reviewer_TwoTildeV1\n~Celeste_Martinez1'''
 
         recruitment_note = test_client.post_note(openreview.Note(
             content={
@@ -641,6 +641,7 @@ def test_venue_recruitment_tilde_IDs(self, client, test_client, selenium, reques
                                                                                    venue['request_form_note'].number)
         last_comment = client.get_notes(invitation=recruitment_status_invitation, sort='tmdate')[0]
         assert '2 users' in last_comment.content['invited']
+        assert '"invalid_profile_ids\": [\n    \"~Celeste_Martinez1\"\n  ]\n}' in last_comment.content['error']
 
     def test_venue_AC_recruitment_(self, client, test_client, openreview_client, selenium, request_page, venue, helpers):