@@ -95,7 +95,7 @@ def _user_search_by_email(
9595 session : OAuth2Session , users : list ["User" ]
9696) -> StateOrOperationGenerator :
9797 """Perform a search for a set of users by email"""
98- users_by_email = {user .email : user for user in users }
98+ users_by_email = {user .email . lower () : user for user in users }
9999
100100 payload = {
101101 "schemas" : [SchemaURI .SERACH_REQUEST ], # typo in upstream lib
@@ -127,12 +127,18 @@ def _user_search_by_email(
127127 for resource in resources :
128128 email = first (
129129 [
130- email ["value" ]
130+ email ["value" ]. lower ()
131131 for email in resource .get ("emails" , [])
132132 if email .get ("primary" , False )
133133 ]
134134 )
135- if email is not None :
135+ if email is None :
136+ log .error ("Unexpected user result with no email" )
137+ elif email not in users_by_email :
138+ log .error (
139+ "Received an email in search results that does not match: %s" , email
140+ )
141+ else :
136142 yield UserState (users_by_email [email ], resource ["id" ])
137143
138144 if not resources :
@@ -232,7 +238,7 @@ def _perform_sync_operations(
232238 bulk_id = operation ["bulkId" ]
233239 user = users_by_bulk_id [bulk_id ]
234240
235- if operation ["status" ] != str ( http .HTTPStatus .CREATED ) :
241+ if int ( operation ["status" ]) != http .HTTPStatus .CREATED :
236242 log .error (
237243 "Unable to perform operation for user: %s, response: %s" ,
238244 str (user ),
0 commit comments