diff --git a/discovery-provider/src/tasks/entity_manager/user.py b/discovery-provider/src/tasks/entity_manager/user.py index 45428d59e9b..1e6b57f88b7 100644 --- a/discovery-provider/src/tasks/entity_manager/user.py +++ b/discovery-provider/src/tasks/entity_manager/user.py @@ -67,14 +67,15 @@ def validate_user_tx(params: ManageEntityParameters): def validate_user_metadata(session, user_record: User, user_metadata: Dict): # If the user's handle is not set, validate that it is unique if not user_record.handle: + handle_lower = user_metadata["handle"].lower() user_handle_exists = session.query( - session.query(User).filter(User.handle == user_metadata["handle"]).exists() + session.query(User).filter(User.handle_lc == handle_lower).exists() ).scalar() if user_handle_exists: # Invalid user handle - should not continue to save... raise Exception(f"User handle {user_metadata['handle']} already exists") user_record.handle = user_metadata["handle"] - user_record.handle_lc = user_metadata["handle"].lower() + user_record.handle_lc = handle_lower # If an artist pick track id is specified, validate that it is a valid track id if (